
864 N.E.2d 890 (2006)
Lakeshore DECARO, f/k/a LakeShore Digital Imaging, Inc., Plaintiff-Appellee and Defendant-in-Intervention-Appellee,
v.
M. FELIX, INC., d/b/a Lake Shore Digital Imaging, Inc. and Color Com, MICHAEL FELIX, and Genaro Felix, Defendants (Stewart Title Guaranty Company, Plaintiffs-in-Intervention-Appellant).
No. 1-05-2460.
Appellate Court of Illinois, First District, Fifth Division.
March 9, 2007.
*892 Cohon Raizes & Regal LLP, Chicago (J. Michael Williams, Cheryl A. Perry, of counsel), for Plaintiff-in-Intervention-Appellant.
Fuchs & Roselli, Ltd., Chicago (Richard C. Perna, Joonho Yu, of counsel), for Plaintiff-Appellee and Defendant-in-Intervention-Appellee.
Presiding Justice SHEILA M. O'BRIEN delivered the opinion of the court:
Genaro Felix (Felix) owned some real property for which there were two existing mortgage liens. Lakeshore Decaro (Lakeshore) subsequently obtained an $80,000 arbitration award against Felix and recorded a memorandum of judgment against the property. After Lakeshore recorded its judgment, Felix entered into a contract to sell the property to Burke Chaney Builders (Burke Chaney). In connection with the purchase and sale of the property, the First National Bank of Brookfield (the Bank) lent Burke Chaney $104,8000 and received a mortgage on the *893 property in the same amount. A portion of the loan proceeds was used to pay off the two prior mortgages and Cook County real estate taxes. The primary question on appeal is whether the Bank's mortgage lien was subrogated to the lien position of those earlier mortgages and taxes ahead of the judgment lien of Lakeshore. We answer the question in the affirmative, holding that the Bank's mortgage lien on the property is superior to Lakeshore's judgment lien.
This matter relates to real property at 8015 Christie Avenue in Lyons, which was owned by Felix and encumbered by two preexisting mortgages, each of which had been duly recorded. On November 8, 2002, Lakeshore recorded its memorandum of judgment in the amount of $80,000 against the property.
On December 6, 2002, Felix closed the sale of the property to Burke Chaney. The purchase price was $131,000. In connection with the purchase and sale of the property, the Bank made a mortgage loan to Burke Chaney in the amount of $104,800. The proceeds of the Bank's mortgage loan were used to pay off the two prior mortgages in the amounts of $57,468.32 and $25,278.60. The proceeds of the mortgage loan also were used to pay off Cook County real estate taxes in the amount of $3,294.60. At the closing, Felix received $36,798.23 from the sale of the property to Burke Chaney.
Prior to closing, Burke Chaney and the Bank obtained commitments for title insurance from Stewart Title. Neither the commitments nor the owner's and lender's policies eventually issued by Stewart Title to Burke Chaney and the Bank disclosed Lakeshore's memorandum of judgment.
In January 2003, Lakeshore instituted postjudgment proceedings against Felix. In November 2003, Lakeshore sent Burke Chaney, the Bank, and Stewart Title notice of a sheriff's levy sale of the property scheduled for December 16, 2003. On December 12, 2003, Burke Chaney and the Bank filed an emergency petition to intervene in this matter, as well as an emergency motion to stay the scheduled sheriff's sale. In the emergency petition to intervene, Burke Chaney and the Bank sought a determination that the Bank's mortgage lien on the property was superior to Lakeshore's judgment lien by virtue of subrogation, on the theory that proceeds from its mortgage loan had been used to pay off the two senior mortgages and the Cook County real estate taxes. Burke Chaney and the Bank sought to stay or temporarily restrain the sheriff's levy sale until the lien priority issues could be determined.
The trial court denied the motion to stay or restrain the sheriff's sale. Lakeshore then purchased the property at a sheriff's sale on December 16, 2003, for the sum of $83,000.
Following the sheriff's sale, Burke Chaney and the Bank decided to redeem the property. Prior to redeeming the property, though, they filed a motion to allocate the proceeds of redemption. In the motion to allocate, they argued that Lakeshore was not entitled to the entire redemption amount, but that, at best, Lakeshore was only entitled to the net proceeds Felix received from the sale of the property, in the amount of $36,798.23. They further contended that a hearing may be necessary to determine whether the property was Felix's homestead; if Felix had homestead rights in the property, then Lakeshore was only entitled to $29,298.23 (which represented the difference between $36,798.23 and the $7,500 homestead exemption.)
On June 8, 2004, the trial court denied the motion to allocate the proceeds of redemption. On June 15, 2004, Stewart Title, *894 acting under both the owner's policy of title insurance issued to Burke Chaney and the lender's policy of title insurance issued to the Bank, provided the funds necessary to redeem the property. Such funds amount to $87,143.18.
On May 5, 2005, Stewart Title was allowed to substitute as plaintiff in intervention, in place of its insureds, Burke Chaney and the Bank. The reason for the substitution was that Stewart Title had provided the funds for the redemption of the property and had become the real party in interest.
Stewart Title filed an amended complaint in intervention, alleging that the trial court had erred in denying the motion to stay and the motion to allocate the proceeds of redemption. Stewart Title alleged that Lakeshore had been unjustly enriched in the amount of $53,701.77, which represented the difference between the $83,000 which Lakeshore received from the redemption of the property, and the $29,298.23 which Lakeshore should have received.
The trial court dismissed Stewart Title's amended complaint in intervention for failure to state a cause of action. Stewart Title filed a notice of appeal seeking review of the order denying the motion to stay, the order denying the motion to allocate the proceeds of redemption, and the order dismissing its amended complaint in intervention.
The appeal of the order denying the motion to stay or restrain the sheriff's sale is moot, as the sheriff's sale has been made, and the parties are now disputing the allocation of the proceeds. Accordingly, we address the appeal of the order denying the motion to allocate and the order dismissing Stewart Title's amended complaint in intervention.

I. The Order Denying the Motion to Allocate the Redemption Proceeds
Initially, Lakeshore contends that the motion to allocate sought injunctive relief (i.e., an injunction directing the sheriff to accept an amount less than the price successfully bid by Lakeshore as a valid redemption of the property) and that, pursuant to Supreme Court Rule 307(a)(1) (188 Ill.2d R. 307(a)(1)), an interlocutory appeal should have been taken. Since no interlocutory appeal was taken, Lakeshore contends that the appeal should be dismissed for lack of jurisdiction.
Lakeshore's contention is without merit. Our supreme court has held that while Rule 307(a)(1) confers on parties the right to appeal certain interlocutory orders before entry of final judgment, the rule does not require that such an interlocutory appeal must be taken. Salsitz v. Kreiss, 198 Ill.2d 1, 11, 260 Ill.Dec. 541, 761 N.E.2d 724 (2001). Rather, the party has the option of waiting until after final judgment has been entered before seeking review of the interlocutory order. Salsitz, 198 Ill.2d at 11, 260 Ill.Dec. 541, 761 N.E.2d 724. In the present case, Stewart Title timely filed its appeal after the trial court's final judgment dismissing its amended complaint in intervention. Accordingly, we have jurisdiction to hear the appeal.
Lakeshore next contends that the motion to allocate the redemption proceeds was procedurally improper, because there was no underlying pleading requesting injunctive relief. In support, Lakeshore cites American Federation of State, County, & Municipal Employees, Council 31 v. Ryan, 332 Ill.App.3d 866, 870, 266 Ill.Dec. 4, 773 N.E.2d 739 (2002), which held that "the right to injunctive relief necessarily brings into question the sufficiency of the complaint." Contrary to Lakeshore's argument, *895 the record shows that Burke Chaney and the Bank filed an underlying pleading to which was attached a proposed complaint in intervention. The proposed complaint in intervention contained a count for preliminary and permanent injunctive relief.
Lakeshore also contends that the motion to allocate the redemption proceeds failed to properly plead all the elements required for injunctive relief. A party seeking injunctive relief must demonstrate (1) a clear and ascertainable right in need of protection; (2) irreparable harm if injunctive relief is not granted; (3) no adequate remedy at law; and (4) reasonable likelihood of success on the merits. Allen v. Illinois Community College Board, 315 Ill.App.3d 837, 848, 248 Ill.Dec. 635, 734 N.E.2d 926 (2000). The motion to allocate alleged irreparable loss of the Bank's lien interests for which no remedy at law would be adequate, and a reasonable likelihood of success on the merits based on existing case law (discussed below.) Accordingly, injunctive relief was properly pleaded. We proceed to address the merits of the appeal from the order denying the motion to allocate.
As discussed, this appeal arises from a dispute concerning lien priority. To recap, the real property at issue was owned by Felix and encumbered by two preexisting mortgages. Lakeshore subsequently recorded an $80,000 judgment against the property. Felix then sold the property to Burke Chaney, which secured a mortgage loan from the Bank. A portion of the loan proceeds was used to pay off the two prior mortgages and Cook County real estate taxes. The issue: whether the Bank's mortgage lien was subrogated to the lien position of those earlier mortgages and taxes ahead of the judgment lien of Lakeshore.
Young v. Morgan, 89 Ill. 199 (1878), and Cochran v. Cutler, 39 Ill.App.3d 602, 350 N.E.2d 59 (1976), are dispositive. In Young, Whitehead, the owner of real property, gave a trust deed to Steele in 1873 to secure a loan from Steele. In March 1875, Young, a judgment creditor of Whitehead, recorded two judgments in the county in which the property was located. Young, 89 Ill. at 200. The judgments became liens upon the property. Young, 89 Ill. at 200. Thereafter, in February 1876, Whitehead conveyed the property to Morgan. Young, 89 Ill. at 200. As part of the purchase price, Morgan caused the loan from Steele to be paid off, and Steele executed a release of the trust deed. Young, 89 Ill. at 200.
In July 1876, Young brought an action to sell the property by means of a sheriff's levy, and in August 1876 the property was so sold. Young, 89 Ill. at 200-01. Young was the successful bidder, and he received a certificate of sale from the sheriff. Young, 89 Ill. at 201.
Morgan then filed suit to set aside the sale on the grounds that the trust deed which he paid off was superior to the judgment liens of Young. Young, 89 Ill. at 201. The circuit court granted the relief prayed for and set aside the sheriff's levy. Young, 89 Ill. at 201. The supreme court affirmed, holding:
"The trust deed here was the older and paramount lien to that of the judgments, and had the question been one between Steele, to whom the trust deed was given, his debt being unpaid, and Young, the judgment creditor, there can be no doubt the former would have been entitled to precedence; and the point of inquiry is, whether the same preference exists in favor of the appellee, Morgan, who paid to Steele the debt secured by his trust deed. It is the manifest right *896 and equity of the case that it should." Young, 89 Ill. at 201.
In Cochran, judgment creditors recorded a memorandum of judgment against the judgment debtors' property. Cochran, 39 Ill.App.3d at 605, 350 N.E.2d 59. On March 28, 1972, the judgment debtors sold the property to the third-party buyers. Cochran, 39 Ill.App.3d at 605, 350 N.E.2d 59. The third-party buyers paid off an existing vendor's lien that was prior in time and superior to the judgment lien and also paid off county real estate taxes. Cochran, 39 Ill.App.3d at 605, 609, 350 N.E.2d 59. The third-party buyers executed a mortgage in favor of their lender. Cochran, 39 Ill.App.3d at 604, 350 N.E.2d 59.
The judgment creditors brought suit against the third-party buyers and their mortgagee, seeking to have the judgment lien declared superior to the mortgage. Cochran, 39 Ill.App.3d at 604, 350 N.E.2d 59. The appellate court held that to the extent the third-party buyers and their mortgagee paid off the liens and encumbrances incurred by the judgment debtors prior to the filing of the judgment lien, "they would be equitably entitled to be subrogated to the rights of the original vendor and tax lienor and to assert those rights in the distribution of the proceeds of any sale." Cochran, 39 Ill.App.3d at 609, 350 N.E.2d 59, citing Young v. Morgan, 89 Ill. 199 (1878).
Similar to Young and Cochran, the funds provided by the Bank were used to pay off the two preexisting mortgages and real estate taxes incurred prior to the filing of Lakeshore's $80,000 judgment lien. As such, the Bank's mortgage lien was subrogated to the lien positions of those earlier mortgages and taxes and therefore is superior to Lakeshore's judgment lien.
Lakeshore contends, though, that it would be inequitable to subrogate the Bank's mortgage lien to the lien position of the earlier mortgages and taxes. Lakeshore's contention is without merit, where Young and Cochran held that equity favors such subrogation.
Having determined that the Bank's mortgage lien is subrogated to the lien position of the earlier mortgages and taxes and is superior to Lakeshore's judgment lien, we next must review the allocation of the proceeds of redemption. This issue was never fully addressed by the trial court, which effectively determined that the Bank's mortgage lien was not subrogated to the lien position of the earlier mortgages and taxes and which denied the motion to allocate. The trial court also never considered the effect of the homestead exemption on the allocation of funds. Accordingly, we reverse the order denying the motion to allocate and remand for the trial court to allocate the redemption proceeds consistent with this opinion.

II. The Order Dismissing Stewart Title's Amended Complaint in Intervention
Stewart Title filed an amended complaint in intervention, alleging unjust enrichment against Lakeshore. The trial court dismissed the amended complaint pursuant to section 2-615 of the Code of Civil Procedure (735 ILCS 5/2-615 (West 2000)) for failure to state a cause of action. "The question presented by a section 2-615 motion to dismiss is whether the allegations of the complaint, when viewed in a light most favorable to the plaintiff, are sufficient to state a cause of action upon which relief can be granted." Abbasi v. Paraskevoulakos, 187 Ill.2d 386, 391, 240 Ill.Dec. 700, 718 N.E.2d 181 (1999). "A cause of action will not be dismissed on the pleadings unless * * * no set of facts can be proved which will entitle the plaintiff to recover." Abbasi, 187 Ill.2d at 391, 240 Ill.Dec. 700, 718 N.E.2d 181. Review is de novo. Abbasi, 187 Ill.2d at 391, 240 Ill. Dec. 700, 718 N.E.2d 181.
*897 A defendant is unjustly enriched when he retains a benefit to plaintiff's detriment and defendant's retention of the benefit violates the fundamental principles of justice, equity, and good conscience. HPI Health Care Services, Inc. v. Mt. Vernon Hospital, Inc., 131 Ill.2d 145, 160, 137 Ill.Dec. 19, 545 N.E.2d 672 (1989).
Stewart Title alleged that Lakeshore was unjustly enriched in the amount of $53,701.77. Stewart Title alleged that the amount of $53,701.77 represented the difference between the $83,000 which Lakeshore received from the redemption of the property, and the $29,298.23 which Lakeshore should have received had the trial court properly found that the Bank's mortgage lien was superior to Lakeshore's judgment lien.
As discussed, the Bank's mortgage lien is superior to Lakeshore's judgment lien, such that the trial court, on remand, must recalculate the amount of monies properly owed to Lakeshore. As the trial court ultimately may determine on remand that Lakeshore was not entitled to the full $83,000 redemption amount, Stewart Title's amended complaint in intervention states a cause of action for unjust enrichment.
Lakeshore contends, though, that Stewart Title may not maintain an equitable claim for unjust enrichment, because it had "unclean hands." Specifically, Lakeshore points to Stewart Title's alleged failure to conduct a proper title search that would have identified Lakeshore's $80,000 judgment prior to closing. Stewart Title disputes any negligence or wrongdoing in conducting the title search. Further, in this case, Stewart Title is not asserting an unjust enrichment claim in its own right against Lakeshore but, rather, as subrogee of Burke Chaney and the Bank. In effect, Stewart Title has stepped into the shoes of Burke Chaney and the Bank, neither of which is accused of having "unclean hands." See CNA Insurance Co. v. DiPaulo, 342 Ill.App.3d 440, 442, 276 Ill.Dec. 715, 794 N.E.2d 965 (2003) ("a subrogee `steps into the shoes' of the person whose claim he has paid and may only enforce those rights which the latter could enforce"). Accordingly, Stewart Title's causes of action as subrogee of Burke Chaney and the Bank stand.
For the foregoing reasons, we reverse the orders denying the motion to allocate and dismissing Stewart Title's amended complaint in intervention, and remand for further proceedings.
Reversed and remanded.
GALLAGHER and FROSSARD, JJ., concur.
