Where relief is sought under Article XVI 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 or petitioner has pleaded or established facts which entitle him or her to relief but that he or she 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 or petitioner 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 or respondent to assert additional defenses, to demand a trial by jury, to plead a counterclaim or third party complaint, and to order the plaintiff or petitioner to take additional steps which were not required under the pleadings as previously filed.
735 ILCS 5/16-111