An administrative decision will be set aside as grossly unreasonable where the decision-maker has failed to properly apply its mind to the evidence before it and has reached a conclusion based on ulterior motives, mala fides, or factors outside the terms of reference. However, on review under sections 27 and 28 of the High Court Act, the court's function is to scrutinize the legality of administrative action, not to substitute its own decision for that of the administrator. Where an administrative decision is found to be ultra vires or grossly irregular, the ordinary course is to set it aside and refer the matter back to the authority for a fresh decision, unless exceptional circumstances exist. The court will only depart from this principle where: (a) the end result is a foregone conclusion; (b) further delay could prejudice the applicant; (c) the extent of bias or incompetence makes it unfair to submit to the same jurisdiction; or (d) the court is in as good a position as the administrative body to make the decision.