
367 N.W.2d 148 (1985)
The FIRST NATIONAL BANK OF BELFIELD, Belfield, North Dakota, a banking corporation, Plaintiff and Appellant,
v.
Jeffrey E. BURICH, Defendant and Appellee.
Civ. No. 10783.
Supreme Court of North Dakota.
April 17, 1985.
*150 Howe, Hardy, Galloway & Maus, Dickinson, for plaintiff and appellant; argued by Michael J. Maus, Dickinson.
*151 John O. Holm, Dickinson, for defendant and appellee.
LEVINE, Justice.
The First National Bank of Belfield (Bank) appeals from a district court judgment which dismissed its action on a promissory note against Jeffrey E. Burich (Burich) and awarded Burich $1,518.94 in damages on his counterclaim. We affirm.
This appeal involves a dispute over the failure of Burich to repay a $2,000.00 loan made by the Bank. The underlying events arose in 1980 upon Burich's divorce from Ginger Swinney (Swinney). The divorce decree awarded each party one-half interest in the family home in Belfield. While Swinney was responsible for the monthly mortgage payments, both parties remained liable on the note and mortgage. Subsequently, both Swinney and Burich moved from Belfield, Swinney having failed to make the mortgage payments. Apparently attempting to avoid liability on the mortgage, Burich and Swinney separately quit-claimed each one's respective ownership interest in the home to the other. At no time following the divorce did Burich reside in the home.
In the summer of 1981 Burich returned to Belfield and was contacted by the Bank to refinance the mortgage on the vacant home. Burich and the Bank negotiated a refinancing agreement on September 1, 1981 when Burich executed a new note for $32,385.34, and mortgage. At this time Burich had no ownership interest in the home, having quitclaimed his interest to Swinney earlier that year.
After the new mortgage had been signed the Bank appraised the house and discovered its value was insufficient for Burich to qualify for a federally subsidized loan. The Bank contacted Burich, an experienced carpenter, and suggested that he renovate the home to increase its value in order to qualify for the federally subsidized loan. To finance the renovation the Bank loaned Burich $2,000, as evidenced by a 60-day promissory note signed by Burich on October 20, 1981.
Burich claimed the Bank promised to obtain title to the home from Swinney and that it was this promise which induced him to borrow the $2,000. Although this was disputed by the Bank's president, he was not present during the negotiations for the $2,000 loan. The Bank did not produce the person who was involved.
Burich used the $2,000 to purchase materials for the renovation of the home and additionally contributed $418.95 of his own money for materials and performed 110 hours of labor. In December, 1981 Burich ceased renovations because of the Bank's failure to obtain title to the home from Swinney.
The Bank sued to collect the $2,000 and Burich counter-claimed seeking compensation for the materials and labor he invested in renovating the home, alleging he was entitled to such damages under theories of unjust enrichment and breach of contract.[1]
The case was tried before the district court which found that the $2,000 note was "solicited by the [Bank] and executed by [Burich] upon the [Bank's] representation that [it] would secure a quitclaim deed in which one Ginger Swinney, former wife of [Burich], would deed her interest in the real property to [Burich]." The trial court then concluded as a matter of law that "the considerations for which [Burich] executed the $2,000 note failed entirely inasmuch as the Bank failed to timely secure the title to the real property in [Burich]." The trial court dismissed the Bank's suit and awarded Burich $1,518.95 on his counterclaim for unjust enrichment; the award equals the value of materials and labor Burich expended in renovating the house over and above the loan proceeds. The Bank then appealed.
The first issue on appeal is whether or not the trial court erred in admitting evidence of the Bank's alleged oral promise to obtain title to the home for Burich.
*152 When requested to resolve contractual disputes by interpreting contracts, courts attempt to ascertain and give effect to the parties' intentions. Lambott v. United Tribes Educ. Tech Center, 361 N.W.2d 590 (N.D.1985); North Dakota Century Code § 9-07-03. When a contract is reduced to writing the parties' intentions are to be ascertained from the writing alone if possible. NDCC § 9-07-04. Therefore, parol evidence is generally not admissible to vary or contradict the terms of a written contract such as a promissory note. Farmers & Merchants Nat. Bank v. Ostlie, 336 N.W.2d 348 (N.D.1983); Bye v. Elvick, 336 N.W.2d 106 (N.D.1983); NDCC § 9-06-07.
However, the trial court admitted Burich's testimony concerning the Bank's oral representations as evidence that the consideration for the note had failed. Parol evidence is admissible to prove failure of consideration. Verry v. Murphy, 163 N.W.2d 721 (N.D.1968); Hartford Accident and Indemnity Co. v. Anderson, 155 N.W.2d 728 (N.D.1968). The decision to admit parol evidence is a determination of law and thus fully reviewable on appeal. Schwarting v. Schwarting, 310 N.W.2d 738 (N.D.1981). We conclude the trial court did not err as a matter of law in allowing the parol evidence under the failure of consideration exception to the parol evidence rule. NDCC § 9-06-07. A necessary if not sufficient cause of our agreement with the decision to admit parol evidence of the Bank's promise to obtain title is the Bank's active solicitation of Burich to improve the home and execute the note after its discovery of the home's insufficient value for federal financing.
Having resolved that parol evidence of the Bank's promise to obtain title was properly admitted we turn to the Bank's contention that the trial court erred in dismissing its complaint for failure of consideration.
Burich did not plead failure of consideration as an affirmative defense. North Dakota Rule of Civil Procedure 8(c) requires any matter constituting an affirmative defense, including failure of consideration, to be set forth in the defendant's responsive pleading. Failure to follow this rule generally results in a waiver of the defense. However, the purpose of Rule 8(c) is to prevent surprise from affirmative defenses raised for the first time at trial. See, 27 Fed.Proc.L.Ed. § 62:61. Burich's defense of and counterclaim for breach of contract were so similar in substance to the affirmative defense of failure of consideration as to provide adequate notice of these issues and prevent any surprise at trial. Consequently, the failure to comply precisely with Rule 8(c) is not fatal. Allied Chemical Corp. v. Mackay, 695 F.2d 854 (5 Cir.1983).
The trial court made a conclusion of law that "the consideration for which [Burich] executed the $2,000 note failed entirely inasmuch as the Bank failed to timely secure the title to the real property in [Burich]."[2] The evidentiary basis for this finding was Burich's uncontradicted testimony about the promise to obtain title. The Bank's failure to offer evidence refuting or otherwise explaining Burich's testimony warrants the inference that Burich's statements were true and correct. Verry v. Murphy, supra. The Bank employee who negotiated the $2,000 note, and who Burich testified made the oral promise to obtain title, did not testify.
Failure of consideration may be total or partial.[3]Schaff v. Kennelly, 61 *153 N.W.2d 538 (N.D.1953). There is a total failure of consideration when a party has failed or refused to perform a substantial part of his bargain, Lawrence v. Lawrence, 217 N.W.2d 792 (N.D.1974), thereby defeating the very object of the contract.[4]Poppenga v. Cramer, 250 N.W.2d 278 (S.D. 1977). A total failure of consideration excuses the nonbreaching party from its own duty to perform under the contract. See, Aberle v. North Dakota B & B Perm. & Tem. Per. Sys., 186 N.W.2d 446 (N.D.1971). On the other hand, there is a partial failure of consideration when the failure to perform is insubstantial, Schaff, supra, so that sufficient consideration remains to sustain the contract. Empire Gas Corp. v. Small's LP Gas Co., 637 S.W.2d 239 (Mo. App.1982). Consequently, with a partial failure of consideration the nonbreaching party is not excused from performance but rather is entitled to an award of damages. Ralston Purina Co. v. Jungers, 86 S.D. 583, 199 N.W.2d 600 (1972). The determination that consideration has failed is a question of fact, Sexton v. Southwestern Auto Racing Ass'n, Inc., 75 Ill.App.3d 338, 31 Ill.Dec. 133, 394 N.E.2d 49 (Ill.App. 1979); see also, Farmers & Merch. Nat. Bank of Hatton v. Lee, 333 N.W.2d 792 (N.D.1983); and will not be disturbed on appeal unless clearly erroneous. NDRCivP 52(a).
The Bank argues that there was at most, a partial failure of consideration so that even if it totally failed to perform its obligation to obtain title, the consideration of the $2,000 existed separately from that promise. See, E.E.E., Inc. v. Hanson, 318 N.W.2d 101 (N.D.1982). Under the Bank's theory this independent consideration was sufficient to sustain the contract and Burich's liability on the note.
The trial court determined that the consideration for which Burich executed the $2,000 note is the Bank's promise to obtain the title, failed entirely because the Bank did not timely secure the title to the house in Burich. The trial court deduced it would be an unreasonable interpretation of the contract to conclude that Burich borrowed $2,000 to renovate a home in which he had no ownership interest without relying upon the Bank's promise to obtain title.
The $2,000 loan was meaningless to Burich unless he received title to the home. Essentially, the Bank was the recipient of the enhanced value of the home[5] as a consequence of Burich's investment of the $2,000, as well as his own labor and materials, in renovating the home. In effect, Burich acted as the Bank's agent in receiving the $2,000 and using it to renovate the home. See Public Finance Corp. of Kansas City v. Shemwell, 345 S.W.2d 494 (Mo. App.1961).
The trial court construed the contract in a reasonable manner, NDCC §§ 9-07-08, 9-07-20, and with reference to the circumstances under which it was made. NDCC § 9-07-12. In doing so the trial court determined the Bank's promise to obtain the title was the object and essence of the contract and consequently the Bank's failure *154 to secure the title constituted a total failure of consideration. Because this consideration was the object of the contract upon which the $2,000 loan depended the contract was not severable into separate and distinct considerations, cf. E.E.E., Inc., supra, all parts of the contract being necessarily dependent on each other. Hofmann v. Stoller, 320 N.W.2d 786 (N.D. 1982). Consequently, the Bank's failure to secure the title excused Burich from his duty to perform on the contract, i.e., to pay the $2,000 note. We conclude that this determination is not clearly erroneous.
The trial court further ruled that the Bank did not "timely" obtain the title for Burich. The Bank did secure a quitclaim deed from Swinney to Burich, signed on December 30, 1982 and recorded by the Bank on June 27, 1983, at which time Burich first became aware of the quitclaim deed. There was no agreed time for the Bank to acquire title. However, pursuant to NDCC § 9-07-22 when no time is specified for the performance of an act required to be performed, a reasonable time is allowed. The $2,000 note was due and payable on December 19, 1981 but it was not until approximately one and one-half years later that the Bank finally obtained the title. The trial court's conclusion that this delay was unreasonable is not clearly erroneous.
The Bank next argues the trial court erred in awarding Burich $1,518.95 on his counterclaim on the theory the Bank was unjustly enriched by acquiring the improved home after Burich had contributed labor and materials.
The equitable remedy of unjust enrichment generally rests upon the concept of quasi or constructive contract implied by law and therefore serves as a basis for requiring restitution of benefits conferred in the absence of an express or implied-in-fact contract. Cavalier County Memorial Hospital Association v. Kartes, 343 N.W.2d 781 (N.D.1984). In this instance, an express contract existed between Burich and the Bank and therefore it was error to rely on the theory of unjust enrichment.
However, although the trial court's legal rationale for its award was incorrect, the award itself was not. A correct outcome will not be set aside merely because the trial court assigned an incorrect reason for its decision "if the results are the same under applicable reasons." Avco Financial Services v. Schroeder, 318 N.W.2d 910, 912 (N.D.1982).
In this case Burich was entitled to the award, not on the basis of the Bank's unjust enrichment, but as damages for the Bank's breach of contract to provide title to the home. For the breach of an obligation arising from contract, the measure of damages is the amount which will compensate the party aggrieved for all the detriment proximately caused by the breach. NDCC § 32-03-09. Damages are proximately caused by a breach when they "directly and naturally" flow from the breach. Vallejo v. Jamestown College, 244 N.W.2d 753, 758 (N.D.1976).
Here Burich expended labor and materials in renovating a home in reliance on the Bank's promise to obtain title. Burich testified he would not have done the work but for the Bank's promise to secure the title. Due to the Bank's breach, Burich in effect, contributed labor and materials in improving a home in which he had no ownership interest. To that extent Burich suffered a detriment proximately caused by the breach of contract.
The Bank's final contention is that Burich's award of $1,518.95 should have been barred as a compulsory counterclaim which was not properly pleaded. North Dakota Rule of Civil Procedure 13(a) provides that a pleading must state as a counterclaim any claim which, at the time of serving the pleading, a pleader has against the opposing party if it arises out of the transaction or occurrence that is the subject matter of the opposing party's claim.
Prior to bringing this suit the Bank instituted an action foreclosing on the mortgage on the home. The Bank maintains *155 that because Burich's claim for damages for breach of contract was not pleaded in the foreclosure action it is barred from being raised in the present action as a compulsory counterclaim by NDRCivP 13(a). We disagree.
The purpose of NDRCivP 13(a) is to promote judicial economy by preventing multiplicity of actions and to achieve resolution in a single lawsuit of all disputes arising out of common matters. Southern Constr. Co. v. United States, 371 U.S. 57, 83 S.Ct. 108, 9 L.Ed.2d 31 (1962). Rule 13(a) is particularly directed against one who fails to assert a counterclaim in one action and then institutes a second action in which that counterclaim becomes the basis of the complaint. Southern Constr. Co., supra.[6]
In this instance Burich did not initiate the second action on the note. Rather, the Bank instituted multiple actions against Burich which it now argues all arise out of the same transaction or occurrence. We are not persuaded that Burich's claim should be barred to discourage piecemeal litigation not instigated by Burich.
Nor did Burich's claim for breach of contract arise out of the same transaction that was the subject matter of the Bank's foreclosure suit. The foreclosure action concerned the real estate mortgage and Burich's failure to make the mortgage payments. The substance of the present action is the subsequent $2,000 note. The two are separate transactions and occurrences which do not originate from the same subject matter. Therefore Burich's claim for breach of contract is not barred by NDRCivP 13(a) as a compulsory counterclaim. Cf., Leo Lumber Co. v. Williams, 191 N.W.2d 573 (N.D.1971).
The judgment is affirmed.
ERICKSTAD, C.J., MESCHKE, GIERKE and VANDE WALLE, JJ., concur.
NOTES
[1]  The Bank had earlier instituted a foreclosure action on the home but settled the case when Burich and Swinney quitclaimed their interest in the home to the Bank.
[2]  The determination that consideration has failed is a question of fact and not of law. See, Sexton v. Southwestern Auto Racing Ass'n, Inc., 75 Ill.App.3d 338, 31 Ill.Dec. 133, 394 N.E.2d 49 (Ill.App.1979), infra p. 7. Nevertheless we are not bound by labels imposed by trial courts and accordingly we will treat this conclusion as a factual finding. Metric Const. v. Great Plains Properties, 344 N.W.2d 679 (N.D.1984).
[3]  Failure of consideration should be distinguished from lack of consideration. When there is a lack of consideration no contract is ever formed. Harrington v. Harrington, 365 N.W.2d 552 (N.D.1985). When there is a failure of consideration, a contract, valid when formed, becomes unenforceable because the performance bargained for has not been rendered. Franklin v. Carpenter, 309 Minn. 419, 244 N.W.2d 492 (1976). See also, 1 Williston, Contracts, §§ 119A (3d ed.); 1 Corbin, Contracts, § 133.

Because the generic term "failure of consideration" to describe a breach of contract is potentially misleading its use for that purpose should be discouraged. The term "failure of consideration" covers every case where a contractual obligation is not performed irrespective of the fault of the breaching party. Thus, a failure of consideration may describe nonperformance which does not constitute a breach. A failure to render a promised performance may not be a breach of contract for the reason that performance has become impossible without fault; see, Inches v. Butcher, 104 N.W.2d 556 (N.D.1960), but is nonetheless a failure of consideration discharging the other party from his duty to perform under the contract, giving him the right to the restitution of payments already made or other benefits already conferred. See, 6 Williston, Contracts, § 814 (3d ed.); 6 Corbin, Contracts, § 125; Restatement (2d) of Contracts, § 237, Comment a (1981); Converse v. Zinke, 635 P.2d 882 (Colo.1981).
[4]  The following cases involve total failure of consideration: Korol v. Aronson, 360 N.W.2d 684 (N.D.1985); Lawrence v. Lawrence, 217 N.W.2d 792 (N.D.1974); Aberle v. North Dakota B & B Perm. & Tem. Pers. Sys., 186 N.W.2d 446 (N.D.1971).
[5]  See footnote 1.
[6]  North Dakota Rule of Civil Procedure 13(a) was adopted from a similar federal rule and therefore when construing the rule this court is guided by and gives great deference to federal case law interpreting the federal counterpart. Gruebele v. Gruebele, 338 N.W.2d 805 (N.D. 1983).
