If the plaintiff in an action of replevin obtains an order for replevin and the right of property is adjudged against the plaintiff, judgment shall be entered for a return of the property if such property has been delivered to the plaintiff, and damages for the use thereof from the time it was taken until a return thereof is made, unless the plaintiff shall, in the meantime, have become entitled to the possession of the property, in which event judgment may be entered against the plaintiff for costs and such damage as the defendant has sustained; or if the property was held for the payment of any money, the judgment may be in the alternative that the plaintiff pay the amount for which the same was rightfully held, with proper damages, within a given time, or make return of the property in case such property was delivered to the plaintiff.
735 ILCS 5/19-123