
643 P.2d 1161 (1982)
Roy MAXTED, Plaintiff and Respondent,
v.
Kenneth P. BARRETT and Vola J. Barrett, husband and wife, Defendants and Appellants.
No. 81-469.
Supreme Court of Montana.
Submitted April 5, 1982.
Decided April 26, 1982.
*1162 Small, Hatch & Doubek, Richard J. Pyfer argued, Helena, for defendants and appellants.
Hooks & Budewitz, Patrick F. Hooks argued, Townsend, for plaintiff and respondent.
HASWELL, Chief Justice.
Defendants appeal the trial court decision ordering them to specifically perform their agreement with the plaintiff wherein plaintiff was to purchase defendants' mortgagee's interest in the Denver Block Apartments property in Helena. We affirm.
On March 23, 1979, defendants sold the "Denver Block Apartments" (125 Broadway, Helena) to Benjamin and Annie Brown. Browns assumed a first mortgage held by the Helena American Federal Savings and Loan Association and executed a note to defendants for $67,000 at 9%, secured by a second mortgage. Each monthly payment amounted to $848.74. Insurance payable to the defendants was carried to the extent of the second mortgage's balance.
By the early part of 1980, the Browns were delinquent in their monthly payments and had not paid the real property taxes for 1979. Defendants filed an action to foreclose their second mortgage but did not pursue it, hoping that the Browns would be able to get their financial problems remedied.
In April 1981, plaintiff contacted the defendants regarding the possible purchase of their second mortgagee's interest in the property. The Browns were still in default on the monthly payments and defendants were aware that the City of Helena had ordered the Browns to bring the building up to code by September 1, 1981, or have it be condemned.
On April 15, 1981, plaintiff and defendants signed a realtor's buy-sell agreement (a Stevens-Ness form entitled "Receipt and Agreement to Sell and Purchase") wherein plaintiff purchased defendants interest for $37,500, which was a little over half of what was still due and owing on the note between the defendants and Brown (about $63,000). The parties inserted the following language in the agreement with regard to the $37,500:
"... to be paid in full by June 1st or sooner, depending upon the contingency of rehabilitation loan from American Federal Savings to purchaser. (1981). Seller agrees to sell their entire interest in the Denver Apartments to purchaser upon receipt of the purchase price stated."
Plaintiff paid $100 earnest money at that time. On April 23, 1981, plaintiff agreed with Browns to purchase their interest and receive a deed to the property, effective May 26, 1981. Under that agreement, plaintiff was to assume the Browns' indebtedness, including the second mortgage. On May 25, 1981, fire completely destroyed the building and thereafter plaintiff sent a rescission notice to Browns, stating that the destruction of the building constituted a failure of consideration. On May 29, 1981, plaintiff tendered to defendants a check for $37,400 and an Assignment of Mortgage form. Defendants refused both checks and returned them and the unexecuted Assignment form to plaintiff's attorney.
On June 3, 1981, plaintiff filed suit seeking specific performance of the agreement with defendants. Defendants answered, raising various defenses, including the fact that plaintiff had not obtained the rehabilitation loan as per the agreement and that plaintiff would be unjustly enriched. After depositions, the Court granted plaintiff's motion for summary judgment, the effect of which is to give the plaintiff $25,500 ($63,000 in insurance proceeds less the $37,500 payment to defendants). Defendants appeal.
The insurance carrier has paid the $63,000 in insurance proceeds into the District Court in a separate interpleader action, pending the final determination of this case.
The issue on appeal is whether the lower court erred in granting summary judgment to plaintiff and ordering defendants to specifically perform the April 15 agreement.
*1163 It is clear that either way this case is decided, one of the parties is going to receive a substantial amount of money in insurance proceeds which was not in any of the parties' contemplation at the time of contracting. Bearing this in mind, we proceed to examine the parties' various contentions.
Appellants first argue that the plaintiff was not entitled to specific performance because he failed to perform the contingencies required by the contract, i.e. the contract required the plaintiff to obtain a rehabilitation loan from American Federal Savings and Loan which he failed to do. Plaintiff counters by emphasizing the provision in the contract which states that defendants will transfer their interest to plaintiff on receipt of the purchase price, which defendants failed to do. According to plaintiff, the source of the money is immaterial.
We agree with the plaintiff. The important fact here is that the defendants had received the full $37,500 purchase price by May 29, 1981, and they refused to assign their interest to plaintiff. Appellants emphasis of the need to obtain the funding from American Federal as condition precedent to their performance rings hollow when it is considered that elsewhere in their brief appellants concede that, after the fire, there was no way for plaintiff to obtain a rehabilitation loan because the building no longer existed.
Also, we are mindful of the fact that appellants were willing to rid themselves of Brown as a debtor and accepted an approximate 50% reduction in the value of the note Brown had executed to them. They are now attempting to relieve themselves of this obligation in view of the potential insurance proceeds recovery.
Appellants next argue that specific performance does not lie because the subject matter of the contract was substantially destroyed before the contract was closed. Appellants cite several cases in support of this proposition, including Geist v. Lehmann (1974), 19 Ill. App.3d 557, 312 N.E.2d 42; Wheeler v. Gahan (1924), 206 Ky. 366, 267 S.W. 227 and Gamble v. Garlock (1911), 116 Minn. 59, 133 N.W. 175. Plaintiff argues that most of appellants' cases involve a seller seeking specific performance and are thus distinguishable from the case at bar where the buyer seeks the remedy. Although Wheeler and Gamble both involved optionees being denied specific performance, plaintiff argues they are not in point because an abatement of the purchase price was involved.
In Gamble, plaintiff leased defendant's house and lot with a 90-day option to buy, beginning April 1, 1911. A fire occurred April 27, 1911, and plaintiff attempted to exercise his option with an abatement in price for the destruction of the buildings and furniture. After being refused, plaintiff sued for specific performance with abatement. In denying plaintiff any relief, the Court stated:
"The parties did not contemplate that a fire might occur, and that the offer should still hold good, subject to adjustment of damages. The owner was willing to part with the entire property as it stood for $6,000, but she might not have been willing to sell the land for that price less the amount of damages by a fire." 116 Minn. at 60, 133 N.W. at 176.
In Wheeler, there was a similar lease-option arrangement and while the plaintiff was attempting to exercise his option, a fire destroyed the building and nearly all improvements. The Kentucky Court of Appeals reversed the lower court order, which had granted plaintiff specific performance with an abatement in price, and made the following statements:
"To require specific performance under such changed conditions, not brought about by either party, is to make for the parties a new contract  one not contemplated in their original negotiations. For these reasons we are of opinion that appellee was not entitled to specific performance of the contract, and that the chancellor erred in holding otherwise. 206 Ky. at 370, 267 S.W. at 229.
*1164 However, in neither Gamble nor Wheeler is there any indication that the contract specifically gave the optionee the right to specific performance. Here, paragraph five of the buy/sell states:
"5. The purchaser agrees that this contract does authorize the seller to enforce the remedy of specific performance. The seller agrees that this contract does authorize the purchaser to enforce the remedy of specific performance."
Moreover, we have a statute in Montana which provides for specific performance under the circumstances of this case:
"27-1-411. When specific performance of an obligation may be compelled. Except as otherwise provided in this part and Title 28, chapter 2, parts 16 and 17, the specific performance of an obligation may be compelled when:
"...
"(4) it has been expressly agreed in writing, between the parties to the contract, that specific performance thereof may be required by either party.. ."
We think the above statute and the language of the contract itself favors the application of specific performance in this case.
The next argument appellants make is that plaintiff will be unjustly enriched by the lower court's judgment. While we agree that plaintiff will profit by the results of the lower decision, it is equally apparent that appellants would gain substantially if the decision were reversed. Further, appellants have not cited any case where unjust enrichment was considered dispositive in a specific performance action. This is not surprising due to the distinction between specific performance and unjust enrichment. In a specific performance action, the plaintiff seeks to enforce the terms of an agreement between the parties and the contractual terms must be sufficiently certain so the court can compel performance. Seifert v. Seifert (1977), 173 Mont. 501, 568 P.2d 155; section 27-1-412(6), MCA.
The theory of unjust enrichment and restitution is brought into play when no contract between the parties exists and the court implies a contract in law. One court stated it thus:
"Plaintiff alternatively contends that he is entitled to payment by the defendant under a theory of unjust enrichment or recovery in quasi-contract, which allows the courts to impose a duty to refund money to the person to whom it rightfully belongs. This argument also must fail. A quasi or constructive contract rests upon the equitable principle that a person shall not be allowed to enrich himself at the expense of another. It is an obligation created by law only in the absence of an agreement between the parties. Bradkin v. Leverton, 26 N.Y.2d 192, 309 N.Y.S.2d 192, 257 N.E.2d 643 (1970). As already noted above, where, as here, a written contract does exist, the duty of the courts is to enforce it..." (Emphasis added.) Fox v. Lummus Co. (S.D.N.Y. 1981), 524 F. Supp. 27, 29-30.
Here it is undisputed there was a contract between the parties and appellants unjust enrichment arguments are not well taken. See generally Dobbs, Handbook on the Law of Remedies (1973), § 4.1, p. 222-27.
Appellant's next contention is that specific performance does not lie because there is no mutuality of remedy, citing Schultz v. Campbell (1966), 147 Mont. 439, 413 P.2d 879, which holds in essence that mutuality requires that the decree will operate without injustice or oppression to plaintiff or defendant. Plaintiff, on the other hand, argues that there is mutuality of remedy by the provisions of paragraph five of the buy/sell, supra, which state that both parties shall have the remedy of specific performance and that plaintiff fully performed when he tendered the remaining amount due on May 29, 1981. Both parties cite section 27-1-414, MCA, which provides:
"27-1-414. Right to specific performance to be mutual. (1) When either of the parties to an obligation is entitled to a specific performance thereof according to the provisions of 27-1-411, the other party is also entitled to it, though not within those provisions.

*1165 "(2) Neither party to any obligation can be compelled specifically to perform unless the other party thereto has performed or is compellable specifically to perform everything to which the former is entitled under the same obligation, either completely or nearly so, together with full compensation for any want of entire performance." (Emphasis added.)
Applying the words of the statute to the present circumstances, the appellants were entitled to receive $37,500 for their mortgagee's interest, which, it is uncontroverted, was tendered to them. The source of the money was immaterial until the prospect of insurance proceeds arose. Thus they received everything they were entitled to and could be compelled by the lower court to specifically perform their part of the obligation.
Further, we do not view our decision today as being unjust or oppressive to appellants, Schultz, supra. Appellants were more than ready to rid themselves of Brown as an obligor, as evidenced by their taking a substantial reduction in the sale of the note to plaintiff, and there is nothing unjust or oppressive in requiring them to follow through with their end of the deal. The only thing they are losing is the recovery of insurance proceeds. See section 27-1-415(2) and 27-1-413, MCA.
Finally, appellants contend that the parties contemplated the sale of a building and, since the fire destroyed the building, the agreement is not specifically enforceable. Plaintiff counters by relying on the rule of law that a contract, freely entered into, cannot later be avoided when 20-20 hindsight indicates the terms are not as favorable as they once appeared to be. In support of this opposition, plaintiff cites Hein v. Fox (1953), 126 Mont. 514, 254 P.2d 1076, and Veterans Rehabilitation Center, Inc. v. Birrer (1976), 170 Mont. 182, 551 P.2d 1001.
We do not agree with appellant. While it is true that neither party contemplated the recovery of insurance proceeds when the buy/sell was executed, this does not automatically negate the remedy of specific performance. What we are called on to do here is render a decision in a fact situation beyond the scope of the agreement in the light of subsequent happenings. The fact that every contingency was not included in the agreement does not render it incapable of being specifically performed.
Affirmed.
