11 This declaratory-judgment case involves the priorities of a mortgagee’s recorded interest and the unjust-enrichment claim of an individual who purchased the property from the mortgagors. Appellant Deutsche Bank National Trust Company, which holds a deed of trust on the property, challenges the circuit court’s order declaring that appellee Mike Austin (the purchaser of residential property from David and Sue Swaithes, who were in debt to appellant) was entitled to reimbursement in the amount of $40,732.59 (allegedly for repairs he made to the property) from the first proceeds of any subsequent foreclosure sale of the property by appellant. Because foreclosure has not yet occurred, the issue before us is limited to the parties before us and the priority of these parties’ interests in this property. We reverse.
In March 2000, the Swaitheses gave appellant’s predecessor a deed of trust on the property to secure a note for $57,000. The trustee promptly filed the deed of trust. In |2November 2005, the Swaitheses entered into a contract to sell the property to appellee for $66,000. Appellee, who did not investigate the title before he entered into the contract, paid $10,000 down and agreed to pay the remaining balance to the Swaitheses in monthly installments. The contract expressly referenced the Swaitheses’ deed of trust to appellant’s predecessor. The Swaitheses fell behind in their payments. After receiving a foreclosure notice (which appellee also received) in 2006, the Swaitheses entered into a loan modification, increasing the principal, with appellant’s predecessor on April 1, 2007. After the Swaitheses defaulted again, appellant had title work done in November 2007, which did not disclose appellee’s interest. The title commitment, however, did reveal a second mortgage and numerous tax liens existing at the time that appellee had agreed to purchase the property. On December 27, 2007, after appellee had received a December 12, 2007 trustee’s notice of default and intention to sell the property by statutory-foreclosure sale, he recorded his contract.
Appellee filed this suit in January 2008 against the Swaitheses and appellant, asking for a declaratory judgment establishing his superior ownership rights in the property. He did not expressly ask for “unjust enrichment” but did state that, if he lost his interest in the property, he would be entitled to judgment for the money he had paid the Swaitheses and for his expenses incurred in making improvements to the property. No other interested parties were either named or joined in the lawsuit. The Swaitheses were discharged in bankruptcy, and the bankruptcy court entered an order permitting an in rem proceeding against the property. The Swaitheses executed a quitclaim deed to appellee.
| aDavid Swaithes; appellee; and Mar-shelle Henderson, a loan analyst for the bank’s servicing agent, testified at trial. Over appellant’s objection, the court permitted appellee to introduce into evidence testimony about, and documentation supporting, the $40,752.59 in expenses he alleged he had incurred in making improvements to the property. The circuit court found that appellant had the power to foreclose on the property, to which appel-lee had made substantial improvements. The court also found that appellant would unjustly benefit from appellee’s improvements to the property and ruled that he would be entitled to reimbursement in the amount of $40,732.59 from its sale.
On appeal, appellant argues (1) that ap-pellee failed to timely plead a claim for unjust enrichment; (2) that its interest is superior to that of appellee; and (3) that it has not been unjustly enriched because of appellee’s repairs. In response, appellee argues that, although appellant has a contractual right to foreclose on the property as the first mortgage holder, the trial court correctly balanced the equities between the parties and fashioned an appropriate remedy.
First, we address a procedural matter raised by appellee. He argues that this appeal should be dismissed because appellant has accepted the money that had been paid into the registry of the court ($6,337.41, representing some principal payments and insurance proceeds for hail damage to the property). We disagree. A party may prosecute an appeal from a judgment partly in his favor and partly against him even after accepting the benefit awarded him by the judgment, provided the record discloses that what he recovers is his in any event — that is, whether the judgment be reversed or affirmed. Thomas v. Thomas, 68 Ark.App. 196, 4 S.W.3d 517 (1999). However, he waives his right to an appeal by accepting a benefit that is inconsistent with the claim of right he seeks to establish by the appeal. Shepherd v. State Auto Prop. & Cas. Ins. Co., 312 Ark. 502, 850 S.W.2d 324 (1993). The acceptance of an amount less than the appellant contends is due it is an estoppel against its appeal only when, by seeking to gain more by the appeal, it risks a smaller recovery on reversal. Wilson v. Fullerton, 332 Ark. 111, 964 S.W.2d 208 (1998). Appellant’s appeal is not inconsistent with its acceptance of the escrow amount, which it will be entitled to retain without regard to the outcome of this appeal.
In its first point, appellant contends that the trial court erred in considering appellee’s request for unjust enrichment because he did not timely plead it, pointing out that appellee did not use the term “unjust enrichment” until his posttrial brief and because it objected to appel-lee’s introduction of receipts for his expenses incurred in improving the property as irrelevant, which the court overruled. It is true that appellant did not expressly or implicitly agree to the trial of appellee’s request for unjust enrichment. See Ark. R. Civ. P. 15(b) (2011); McEntire v. Watkins, 73 Ark.App. 449, 43 S.W.3d 770 (2001). However, Rule 15(b) provides that, if evidence is objected to at trial on the ground that it is not within the issues made by the pleadings, the court may allow the pleadings to be amended in its discretion and may grant a continuance to enable the objecting party to meet that evidence. In view of the facts that appellant did not immediately request a continuance and that appellee asked in his complaint for the return of the money he had spent on improving the property if appellant’s interest prevailed, there was no prejudice in the court’s permitting | ¡¡appellee to introduce this evidence. The trial court did not, therefore, abuse its discretion in considering appellee’s request for unjust enrichment.
Appellant next asserts that its deed of trust was superior to appellee’s interest in the property.1 It has long been the law in this state that nothing can be done by the mortgagor, subsequent to the execution of a valid mortgage, that can impair the rights of the mortgagee; the mortgagor can make no contract respecting the mortgaged property that would bind the mortgagee or prejudice his rights. Amstar/First Capital, Ltd. v. McQuade, 42 Ark.App. 185, 856 S.W.2d 326 (1993).2 Further, a mortgagee, after having his deed recorded, is not required to search the record from time to time to see whether other encumbrances have been put upon the land. Id. Appellee does not dispute appellant’s correct statement of the law that he was bound by everything contained within his chain of title. See Tisdale v. Gunter, 194 Ark. 930, 109 S.W.2d 1267 (1937). There is also no dispute that ap-pellee recorded his contract after appellant filed the deed of trust and the loan modification. Appellee further acknowledges that he had constructive notice of appellant’s predecessor’s interest; that he did |finot inspect the title before entering into the contract; and that he had actual notice of appellant’s predecessor’s interest because it was referenced in the contract.
Additionally, the bank’s original deed of trust takes priority over appel-lee’s interest for the increased principal set forth in the loan modification, even though there was evidence that the bank had actual notice of his interest in the property when the loan was modified. Where a mortgage is given to secure a specific debt named, the security will not be extended to cover debts subsequently incurred unless they are of the same class and so related to the primary debt secured that the assent of the mortgagor will be inferred. Security Bank v. First Nat’l Bank, 263 Ark. 525, 565 S.W.2d 623 (1978); Bank of Searcy v. Kroh, 195 Ark. 785, 114 S.W.2d 26 (1938); Hendrickson v. Farmers’ Bank & Trust Co., 189 Ark. 423, 73 S.W.2d 725 (1934). The modified loan satisfied these conditions. The modification agreement recited that at that time, the unpaid principal was $55,345.50 and that $8,104.95 had accrued in unpaid “taxes, insurance premiums, and other expenses necessary to protect or enforce” the bank’s interest. With the added capitalized amount of $8,104.95, the modified principal balance was $63,450.45. Also, the original deed of trust provided that it secured the debt evidenced by the note, “with interest, and all renewals, extensions and modifications of the Note; ... the payment of all other sums, with interest, advanced ... to protect the security of this Security Instrument; and ... the performance of Borrower’s covenants....”
We therefore hold that the trial court erred in finding that appellant would be unjustly enriched unless appellee receives the amount he spent in making repairs “off the top” of any proceeds of foreclosure. For a court to find unjust enrichment, a party must have received 17something of value, to which he or she is not entitled and which he or she must restore. Campbell v. Asbury Auto., Inc., 2011 Ark. 157, 381 S.W.3d 21. There must also be some operative act, intent, or situation to make the enrichment unjust and compensable. Id. at 10, 381 S.W.3d at 36. One who is free from fault cannot be held to be unjustly enriched merely because he or she has chosen to exercise a legal or contractual right. Id., 381 S.W.3d at 36. In short, an action based on unjust enrichment is maintainable where a person has received money or its equivalent under such circumstances that, in equity and good conscience, he or she ought not to retain. Id. Courts will only imply a promise to pay for services where they were rendered in such circumstances as authorized the party performing them to entertain a reasonable expectation of their payment by the party beneficiary. Jones v. Bourassa, 2011 Ark. App. 369, 383 S.W.3d 888.
We note that appellee continued to make improvements to the property in 2007 and 2008 even though he knew as early as 2006 that the Swaitheses were not paying the debt. The supreme court has affirmed a trial court’s refusal to award unjust enrichment for improvements that might have enhanced the property’s value when the appellant had undertaken them at his own risk. See Childs v. Adams, 322 Ark. 424, 909 S.W.2d 641 (1995). Although the parties devote part of their briefs to arguing about when appellant became aware of appellee’s interest in the property, that is not relevant in light of the fact that appel-lee was always aware of the Swaitheses’ debt to appellant; he failed to inspect the title before he entered into the contract; he was aware of the Swaitheses’ problems paying the debt in 2006, which necessitated the modification of the loan agreement; and he continued to pay the Swaitheses without | ¡^ascertaining whether they were sending their payments to appellant. In contrast, appellant’s behavior was neither culpable nor negligent.
The parties are the assignees of the original mortgagee and debtors, whose arm’s-length transaction was expressed in a written contract. It is generally held that, where there is an express contract, the law will not imply a quasi- or constructive contract. Coleman’s Serv. Ctr., Inc. v. Fed. Dep. Ins. Corp., 55 Ark. App. 275, 935 S.W.2d 289 (1996). The existence of a valid written contract ordinarily precludes recovery in quasi-contract for events arising out of the same subject matter. Servewell Plumbing, LLC v. Summit Contractors, Inc., 362 Ark. 598, 210 S.W.3d 101 (2005). There are exceptions to the general rule when circumstances surrounding the parties’ dealings can be found to have given rise to an obligation to pay. Id. Examples of such exceptions include those in which there has been a rescission at law; where a contract has been discharged by impossibility or frustration of purpose; or where the parties to a contract find they have made some fundamental mistake about something important in their contract. Friends of Children, Inc. v. Marcus, 46 Ark.App. 57, 876 S.W.2d 603 (1994). The mere existence of a contract between the parties does not automatically foreclose a claim of unjust enrichment. Campbell, 2011 Ark. 157, at 11-12, 381 S.W.3d at 30-31. Although an express contract cannot be circumvented by unjust enrichment, a court of equity may impose the remedy of unjust enrichment to further the ends of justice when the express contract does not exist, is void, does not provide an answer, or fully address a subject. Id., 381 S.W.3d at 38. This is not such a case, however.
|9Courts should be hesitant to employ a quasi-contractual theory of recovery where an underlying express contract already exists and fairly-distributes the risks among the parties involved. Sparks Reg’l Med. Ctr. v. Blatt, 55 Ark. App. 311, 935 S.W.2d 304 (1996). Here, the trial court based its decision on the entire amount appellee spent on improving the property, regardless of whether the foreclosure proceeds would be sufficient to satisfy the debt or whether appellant would actually receive a benefit from ap-pellee’s improvements, which will not be known until the foreclosure sale is actually held. An unjust-enrichment award is generally based upon the value of the benefit conferred upon the party unjustly enriched. Jones, 2011 Ark. App. 369, at 4, 383 S.W.3d at 891. “In general, recovery for unjust enrichment is based upon what the person enriched has received rather than what the opposing party has lost.” Grisanti v. Zanone, 2010 Ark. App. 545, at 6, 336 S.W.3d 886, 890.
Reversed.
VAUGHT, C.J., agrees. HART, J., concurs.. Appellant raises another problem created by the trial court’s decision — whether appellee’s entitlement to an unjust-enrichment recovery "off the top” of the as-yet-to-be-determined foreclosure proceeds can affect the interests of the junior lienholders. We do not address that question because the junior lienholders were not parties to this action. Neither the trial court’s ruling nor this court’s decision will affect their interests. It is well settled that all persons whose rights might be affected by the determination of a controversy involving land must be made parties to an action. Williams v. Hall, 98 Ark.App. 90, 250 S.W.3d 581 (2007). The general rule is that a judgment entered without jurisdiction of the person is void. Id.
. See also Bisbee v. Decatur State Bank, 2010 Ark. App. 459, 376 S.W.3d 505 (addressing purchase-money mortgages).