
8 Cal.App.4th 125 (1992)
10 Cal. Rptr.2d 58
CALIFORNIA FEDERAL BANK, Plaintiff and Appellant,
v.
BILL ALBIN MATREYEK, as Trustee, etc., Defendant and Respondent.
Docket No. B059760.
Court of Appeals of California, Second District, Division Three.
July 20, 1992.
*127 COUNSEL
Stell, Levine, Bookman & Weiss and Lawrence E. Bookman for Plaintiff and Appellant.
Covington & Crowe and Melanie Fisch for Defendant and Respondent.
OPINION
KLEIN, P.J.
Plaintiff and appellant California Federal Bank (CalFed) appeals a judgment of dismissal following the sustaining of a demurrer to its original complaint interposed by defendants and respondents Bill Albin *128 Matreyek, as trustee for the Bill Albin Matreyek Trust and Mary Elizabeth Burney Matreyek Trust U/D/T June 9, 1986 (hereafter, the Matreyeks).
The issues presented are whether CalFed has pled or is capable of pleading causes of action for unjust enrichment and equitable subrogation.
For the reasons discussed below, the judgment is affirmed.

FACTUAL AND PROCEDURAL BACKGROUND
On December 3, 1990, CalFed filed this action against the Matreyeks for (1) restitution based on unjust enrichment; (2) equitable subrogation; (3) money had and received; and (4) money paid. The complaint alleged, in relevant part:
On June 8, 1988, pursuant to a note secured by a deed of trust, CalFed loaned the Matreyeks $7,060,000, at an annual interest rate of 10.25 percent. The note required monthly payments of $62,047 through July 1, 1995, at which time the entire principal balance then owing would be due. The note further provided the Matreyeks would owe CalFed a prepayment penalty in the event the note were repaid early. (CalFed did not attach a copy of the note as an exhibit to its complaint.)
In May 1988, CalFed entered into a written agreement with the Federal National Mortgage Association (Fannie Mae), wherein Fannie Mae committed to purchase and fund the subject loan, while CalFed would provide servicing of the loan. The Fannie Mae commitment required CalFed to collect from the Matreyeks and to pay to Fannie Mae a prepayment penalty in the event of an early payoff.
Pursuant to the commitment, Fannie Mae funded the loan, and on June 28, 1988, CalFed assigned the note and deed of trust to Fannie Mae.
On September 22, 1989, in response to a request from the Matreyeks, CalFed advised them they could obtain substitute financing and pay off the loan without incurring any prepayment penalty. This advice was given in good faith but was erroneous.
In December 1989, the Matreyeks paid off the principal balance and accrued interest which was then due and owing on the note. Under the mistaken belief that no prepayment penalty was due, CalFed caused the note to be cancelled and the deed of trust to be reconveyed without requesting the prepayment penalty from the Matreyeks.
*129 Thereafter, CalFed discovered it should have assessed the prepayment penalty at the time of the payoff. Due to CalFed's error, on July 10, 1990, it was required to pay Fannie Mae the prepayment penalty in the amount of $653,998.74.[1]
CalFed notified the Matreyeks its earlier advice regarding the prepayment penalty had been erroneous and it made written demand upon them to repay that full sum to CalFed. The Matreyeks refused. The Matreyeks received a net economic benefit as a result of the note payoff in that they obtained substitute financing with Mutual of New York (MONY) at an interest rate of 9 percent per annum, 1.25 percent less than the CalFed loan. Even after deducting the MONY refinancing costs, the Matreyeks derived a net benefit of about $358,239.03 by refinancing without incurring the prepayment penalty. The Matreyeks refused to pay any part of that sum.
In the first cause of action, unjust enrichment, CalFed pled the Matreyeks had been unjustly enriched by enjoying the more favorable substitute financing without paying the prepayment penalty.
In the second cause of action for equitable subrogation, CalFed pled it paid the prepayment penalty to Fannie Mae in order to protect its own interest, the Fannie Mae commitment obligated CalFed to pay the prepayment penalty in the event of an early payoff of the Matreyek note, and the Matreyeks were primarily liable for the prepayment penalty while CalFed was secondarily liable.[2]
The Matreyeks demurred, arguing, inter alia, CalFed bore the risk of loss from its unilateral mistake and therefore had no right to restitution, CalFed failed to allege the Matreyeks had been unjustly enriched, and CalFed waived its right to the prepayment penalty.
The trial court heard the matter and took it under submission. Later, it ruled: "Both counsel admit that there are no cases on the facts of this case. [¶] ... [¶] Borrower, relying on Bank's promise, changed its position by obtaining re-financing and paid bank in full without paying the pre-payment penalty. Bank confirmed this agreement by cancelling the promissory note and issuing a reconveyance of the trust deed.... All of this is routine every day commercial banking practices which a sophisticated party, like bank, understands and encourages. The story should end here. [¶] Unfortunately for bank, Fannie Mae refused to waive the pre-payment clause. Bank *130 rather than litigating with Fannie Mae, based on bank's reliance on Fannie Mae's policy of previous waivers, paid the pre-payment penalty to Fannie Mae. Bank now seeks reimburs[e]ment from borrower of the pre-payment penalty, [15] months after cancelling the note and issuing the reconveyance in the sum of $350,000[.] [¶] It is the Court's opinion that the bank had plead a classic example of both waiver and estoppel [in favor of the Matreyeks]. The bank has the contractual power to waive the pre-payment clause and did so. Borrower detrimentally relied on bank's promise by obtaining substituted re-financing which bank accepted.... [¶] The fact that bank was mistaken in its reliance on Fannie Mae is not a basis for a cause of action against its borrower. It has both waived its rights and is estopped by its own conduct and borrower's detrimental reliance as pled. [¶] Demurrer sustained as to all causes of action without leave to amend." (Italics deleted.)
Following entry of the judgment of dismissal, CalFed appealed.

CONTENTIONS
CalFed contends its causes of action for (1) restitution based on unjust enrichment and (2) equitable subrogation are well pled.

DISCUSSION

1. Standard of appellate review.

(1) The function of a demurrer is to test the sufficiency of a pleading by raising questions of law. (Buford v. State of California (1980) 104 Cal. App.3d 811, 818 [164 Cal. Rptr. 264].) When a demurrer is sustained, we determine whether the complaint states facts sufficient to constitute a cause of action. (Blank v. Kirwan (1985) 39 Cal.3d 311, 318 [703 P.2d 58].) The allegations are regarded as true and are liberally construed with a view to attaining substantial justice. (Shaeffer v. State of California (1970) 3 Cal. App.3d 348, 354 [83 Cal. Rptr. 347]; King v. Central Bank (1977) 18 Cal.3d 840, 843 [135 Cal. Rptr. 771, 558 P.2d 857].)
Generally, when a demurrer is sustained without leave to amend, we decide whether there is a reasonable possibility the defect can be cured by amendment. If it can be, the trial court has abused its discretion and we reverse; if not, there has been no abuse of discretion and we affirm. (Blank v. Kirwan, supra, 39 Cal.3d at p. 318.)
However, where, as here, a demurrer is sustained to the original complaint, denial of leave to amend constitutes an abuse of discretion if the *131 pleading does not show on its face that it is incapable of amendment. (King v. Mortimer (1948) 83 Cal. App.2d 153, 158 [188 P.2d 502].)

2. Trial court properly sustained demurrer without leave to unjust enrichment count.


a. General principles.

(2) A person who has been unjustly enriched at the expense of another is required to make restitution. (Rest., Restitution, § 1.)
A person is enriched if he or she has received a benefit. (Rest., supra, § 1, com. a.) A benefit is conferred not only where one adds to the property of another, but also where one saves the other from expense or loss. Thus, the term benefit denotes any form of advantage. (Rest., supra, § 1, com. b.) However, the mere fact a person benefits another is not of itself sufficient to require the other to make restitution therefor. The recipient of the benefit is liable only if the circumstances are such that, as between the two persons, it is unjust for the recipient to retain it. (Rest., supra, § 1, com. c.)
Section 12 of the Restatement of Restitution, pertaining to unilateral mistake in bargains, provides: "A person who confers a benefit upon another, manifesting that he does so as an offer of a bargain which the other accepts or as the acceptance of an offer which the other has made, is not entitled to restitution because of a mistake which the other does not share and the existence of which the other does not know or suspect."
Comment a thereto explains: "The equitable principle by which a person is entitled to restitution for what he has transferred to another by mistake is modified by the principle that a person is entitled to the benefit of a bargain made by him without fraud or duress. Ordinarily, therefore, a person entering into a transaction in which another gives or promises consideration is not entitled to the return of what he gives merely because he is mistaken as to ... facts which cause him to enter into the transaction. A contracting party who is unaware of and does not share the mistake made by the transferor, is entitled to retain that which he has received if what he gives is sufficient consideration for a simple contract, ... The consideration which when bargained for will support a simple contract may consist of an act other than a promise, a return promise, a forbearance, or the creation, modification or destruction of a legal relation...." (Rest., supra, § 12, com. a.)
These principles are illustrated in International U. of Op. Eng., L. 953 v. Central N.L. Ins. Co. (10th Cir.1974) 501 F.2d 902, certiorari denied. In that *132 case, various unions brought a breach of contract action against an insurance company for damages arising out the insurer's unlawful cancellation of an insurance policy. (Id., at p. 903.) The issue presented was whether the mistake of the insurer's agent in computing the premium rate was grounds for rescission by the insurer. (Ibid.) The court held the insurer was not entitled to rescind because the plaintiffs neither knew, nor should have known, of the insurer's mistake. (Id., at p. 905.) In fact, the insurer itself did not discover the mistake for over a year. (Ibid.) Also, while the insurer's bid was the low bid, it was in the "`same ball park.'" (Ibid.) Further, it would have been impossible for the plaintiffs to return to the status quo, since they had lost the opportunity to accept the new lowest bid of another company. (Id., at pp. 906-907.) Under the circumstances, the insurer was required to "bear the consequences of its own folly." (Id., at p. 907.)
In contrast, in M.F. Kemper Const. Co. v. City of L.A. (1951) 37 Cal.2d 696, 699-701 [235 P.2d 7], the city had actual notice of a material clerical mistake in a bid on a municipal construction project before it accepted the bid. The court observed relief from such mistakes is allowed "where one party knows or has reason to know of the other's error and the requirements for rescission are fulfilled. [Citations.]" (Id., at p. 701.) However, relief will not be had for mistake of fact if the mistake is the "result of neglect of a legal duty." (Ibid.)

b. Application here.

(3) CalFed clearly conferred a benefit upon the Matreyeks by sparing them the expense of the prepayment penalty. (Rest., supra, § 1, com. b.) For a benefit to be conferred, it is not essential that money be paid directly to the recipient by the party seeking restitution. For example, in Enterprise Leasing Corp. v. Shugart Corp. (1991) 231 Cal. App.3d 737, 748-749 [282 Cal. Rptr. 620], a benefit was conferred upon the defendant because the value of the defendant's use of certain equipment exceeded the rental payments it made under a lease agreement it had not expressly assumed. Similarly, in Sanguansak v. Myers (1986) 178 Cal. App.3d 110 [223 Cal. Rptr. 490], a benefit was conferred upon the borrower when he paid off a promissory note without paying the prepayment penalty. (Id., at pp. 114, 117.)
However, these cases cited by CalFed are not dispositive. For CalFed to be entitled to restitution, in addition to showing it conferred a benefit upon the Matreyeks, CalFed also must show it would be unjust for the Matreyeks to retain the benefit.
In Sanguansak, the debtor could not retain the benefit of a payoff error since he "knew or should have known of the deficiency of the tender because *133 the prepayment charge was clearly stated in the promissory note." (Sanguansak, supra, 178 Cal. App.3d at p. 117.) Similarly, in Katsivalis v. Serrano Reconveyance Co. (1977) 70 Cal. App.3d 200 [138 Cal. Rptr. 620], a borrower was not entitled to retain the benefit of a lender's error in a refinancing transaction. In that case, the new deed of trust was subject to a prior homestead because the new deed of trust was not signed personally by the wife. Instead, it was signed by the husband as attorney in fact for the wife. However, the husband signed that instrument with the wife's authorization. (Id., at pp. 207-209.) Under the circumstances, for the wife to obtain an unqualified cancellation of the note and deed of trust while retaining the benefit of the refinancing would have been unjust. (Id., at p. 209.)
Here, the essential question presented is whether the circumstances are such that, as between CalFed and the Matreyeks, retention of the benefit by the Matreyeks would be unjust. For the reasons explained below, we conclude CalFed's mistake as to Fannie Mae's policy of enforcing prepayment penalties does not entitle CalFed to avoid its agreement with the Matreyeks to forgo the penalty.
First, the complaint discloses the Matreyeks gave valuable consideration in exchange for CalFed's agreement to forgo the prepayment penalty.[3] They repaid the $7,060,000 loan five and one-half years early, which they were not legally obligated to do, and thereby spared the lender from any risk of loss on the loan and freed up the funds for other purposes.
Also, CalFed's willingness to forgo the prepayment penalty was essential to the early payoff by the Matreyeks. The complaint discloses the amount of the prepayment penalty exceeds the net economic benefit to the Matreyeks of refinancing. Therefore, had CalFed not agreed to forgo the prepayment penalty, the Matreyeks would have had no reason to refinance and repay this loan early.
Further, there is no allegation of any impropriety by the Matreyeks. CalFed has not alleged, nor does it contend it can allege, the Matreyeks knew of its mistake and took unfair advantage.[4] Rather, the complaint discloses the Matreyeks specifically asked CalFed whether they could pay off the note early without incurring the prepayment penalty. As between *134 CalFed and the Matreyeks, CalFed was in a superior position to know whether it would insist on collecting the prepayment penalty and the Matreyeks were entitled to rely on CalFed's response. Operating under its own "mistaken belief," CalFed advised no prepayment penalty was required and then proceeded to accept the Matreyeks' full payment of the principal balance and accrued interest.
While CalFed seeks restitution in order to return the parties to the status quo despite its negligent mistake, the status quo cannot be restored. A party seeking restitution "must generally return any benefit" that it has received. (Rest.2d, Contracts, § 376, com. a, § 384, com. a.) However, in repaying the loan early, the Matreyeks entered into substitute financing with MONY. If CalFed were to recover the claimed sum from the Matreyeks, that sum would erase any benefit to the Matreyeks from the refinancing, while CalFed and/or Fannie Mae still would retain the benefit of an early payoff of the $7,060,000 loan. Under the circumstances, recovery by CalFed would be inequitable.
In sum, the Matreyeks were entitled to the benefit of a bargain made by them without fraud, duress, or any knowledge of CalFed's mistake. The mere fact CalFed was mistaken as to the facts which caused it to enter into the early payoff transaction does not entitle CalFed to restitution for unjust enrichment.

3. Equitable subrogation theory similarly unavailing.

(4) Attempting an alternative approach, CalFed contends it is entitled to equitable subrogation because it paid the prepayment penalty the Matreyeks owed to Fannie Mae.
The doctrine of equitable subrogation applies where "`one person, not acting as a mere volunteer or intruder, pays a debt for which another is primarily liable, and which in equity and good conscience should have been discharged by the latter.' [Citations.]" (Caito v. United California Bank (1978) 20 Cal.3d 694, 704 [144 Cal. Rptr. 751, 576 P.2d 466].)
However, CalFed did not pay a debt for which the Matreyeks were primarily liable. The Matreyeks had performed fully by repaying the principal balance and accrued interest. CalFed agreed to and accepted that amount. It cancelled the note and issued a reconveyance. When CalFed subsequently paid Fannie Mae the prepayment penalty, it acted to fulfill its own obligation *135 to Fannie Mae, not to satisfy the Matreyeks' debt, which had been extinguished.

DISPOSITION
The judgment is affirmed. The Matreyeks to recover costs on appeal.
Croskey, J., and Hinz, J., concurred.
NOTES
[1]  We observe CalFed did not plead it received erroneous information from Fannie Mae regarding the Matreyeks' inquiry as to the prepayment penalty. The complaint does not disclose any effort by CalFed to contact Fannie Mae in this regard.
[2]  It is unnecessary to discuss the remaining causes of action because CalFed has not presented any contention in respect to them on appeal.
[3]  Civil Code section 1605, which defines consideration, states: "Any benefit conferred, or agreed to be conferred, upon the promisor, by any other person, to which the promisor is not lawfully entitled, or any prejudice suffered, or agreed to be suffered, by such person, other than such as he is at the time of consent lawfully bound to suffer, as an inducement to the promisor, is a good consideration for a promise."
[4]  In fact, at oral argument, counsel for CalFed conceded CalFed had been negligent and that the Matreyeks were not chargeable with knowledge of CalFed's mistake.
