If the value of the land, aside from the improvements, exceeds the value of the improvements, the court may, in its discretion, order either that the plaintiff shall pay for the improvements before he shall be allowed to take possession of the land, or that the land shall be divided between the occupying claimant and the plaintiff, according to their respective rights.
§ 524.220, RSMo