If the court, after hearing, determines that the commissioner has sustained such burden of proof, the court may set aside the action of the municipality disapproving the establishment or expansion and may enter such order upon such terms and conditions as it deems appropriate to safeguard the rights of the parties and the public.