Where relief is sought under XI of this Act and the court determines, on motion directed to the pleadings, or on motion for summary judgment or upon trial, that the plaintiff has pleaded or established facts which entitle the plaintiff to relief but that the plaintiff has sought the wrong remedy, the court shall permit the pleadings to be amended, on just and reasonable terms, and the court shall grant the relief to which plaintiff is entitled on the amended pleadings or upon the evidence. In considering whether a proposed amendment is just and reasonable, the court shall consider the right of the defendant to assert additional defenses, to demand a trial by jury, to plead a counterclaim or third party complaint, and to order the plaintiff to take additional steps which were not required under the pleadings as previously filed.
735 ILCS 5/11-107