The dispute in this case arose from a contract to construct a log home. The central issues on appeal involve the appropriate measure of damages where both parties to the agreement are in breach. As explained below, we vacate the judgment entered by the district court and remand the case for a recalculation of damages.
*740FACTS AND PROCEDURAL BACKGROUND
Ervin Construction Company (Ervin) contracted to construct a log home for Jay and Shelli Van Orden (the Van Ordens) in Aberdeen, Idaho. The terms of the contract provided that the Van Ordens would make monthly progress payments, allowing the Van Ordens to retain ten percent until final completion, and permitted the Van Ordens to terminate the contract at any time by paying Ervin the appropriate percentage of the contract price based on work completed and the value of the materials. The contract expressly guaranteed the home would be built “in a workman-like manner.”
Construction began in November, 1985. The Van Ordens paid the first four monthly billings for the work completed from November through February. Prior to receiving the March billing, the Van Ordens began to notice defects in the home’s construction, in particular, large gaps in log walls and joints. They voiced their concerns to Ervin at a meeting in April, followed by a letter to Ervin enumerating the defects. Ervin mailed a reply several weeks later acknowledging the need for certain repairs. At the end of the month the Van Ordens received the billing for the work completed in March and April. The Van Ordens told Ervin they would make payment on May 15, and Ervin continued with the construction. On May 15 the Van Ordens handed Ervin a check in payment of the March and April bills. Ervin attempted to deposit the check in its account, unaware that the Van Ordens had post-dated the check to August 15. When the check was returned for insufficient funds on May 21, Ervin promptly notified the Van Ordens that, unless they paid the bill and gave assurances of timely payment in the future, it would immediately withdraw from the job site. Although the Van Ordens were financially capable of paying the bill, they refused to do so. Ervin left the site on May 22. The Van Ordens hired another contractor to complete the home and repair some of Ervin’s defective work. However, the improperly constructed deck and roof structure and the gap between the log walls and roof remained uncorrected. The Van Ordens moved into the home in the fall of 1986, where they resided at the time of trial.
Ervin subsequently brought an action to collect the unpaid balance of approximately $16,000 owing for the work it had completed under the contract. The Van Ordens denied liability and filed various counterclaims alleging theories of breach of contract, breach of warranty, negligence and fraud. The parties tried the case before the district court without a jury. At the conclusion of the evidence, which included testimony from both parties, their experts, and an on-site viewing of the home, the court found that some of Ervin’s work was defective and substandard. Accordingly, the court held that Ervin had breached its express and implied duties under the contract, in that certain parts of the home had not been constructed in a workmanlike manner. The court further held, however, that Ervin’s breach was not substantial, and hence, the Van Ordens’ refusal to pay the monthly billings for March and April was unjustified and constituted a breach of the contract.
In crafting the remedy, the court articulated a concern that the Van Ordens’ unjustified refusal to make payments had essentially forced Ervin off the job and unfairly deprived Ervin of the opportunity to repair its own defective work. Believing an equitable “balance” was in order, the court allowed the Van Ordens to recover only one-half of the $10,348 in costs they had incurred to partially repair Ervin’s defective workmanship. However, the court awarded no damages for the construction defects that were not repaired. In a separate award, the court allowed Ervin to recover the unpaid balance of $15,506 for work it completed under the contract before vacating the job site, plus prejudgment interest on that entire amount, accruing from the time of breach. The court further ruled that Ervin was the overall prevailing party and entitled to its costs and a reasonable attorney fee. The Van Ordens appeal.
ISSUES
On appeal, the Van Ordens raise the following issues:
*7411. Whether the trial court erred in finding the Van Ordens in breach of the contract;
2. Whether the court erred in reducing the Van Ordens’ recovery of costs by one-half;
3. Whether the court erred in failing to award damages for defects that had not been corrected;
4. Whether the court erred in allowing pre-judgment interest on Ervin’s damages award;
6. Whether the court erred in finding that the Van Ordens failed to prove their negligence claim; and
7. Whether the court erred in awarding attorney fees to Ervin.
STANDARD OF REVIEW
Our role in reviewing the factual findings is limited. We do not weigh the evidence, nor do we substitute our view of the facts for that of the trial judge. I.R.C.P. 52(a); Alumet v. Bear Lake Grazing Co., 119 Idaho 946, 949, 812 P.2d 253, 256 (1991). We merely determine whether the findings are supported by substantial, albeit conflicting, evidence in the record. If so supported, such a finding cannot be deemed clearly erroneous. Barber v. Honorof 116 Idaho 767, 780 P.2d 89 (1989). However, we freely review the trial court’s application of the law to the facts found.
BREACH OF CONTRACT
The Van Ordens first contend that the court erroneously found them in breach of the contract for refusing to pay Ervin. They argue that Ervin’s defective construction constituted a substantial and material failure of its promised performance,1 and accordingly they were justified in refusing to make payment. We disagree.
The law of contracts recognizes that a material failure of performance, including defective performance as well as an absence of performance, operates as the nonoccurrence of a condition. See RESTATEMENT (SECOND) OF CONTRACTS § 237 (1981). A party’s material failure of performance has the effect of preventing the other’s duty from becoming due, at least temporarily, and of discharging that duty when the condition can no longer occur. RESTATEMENT, supra, § 237 comment a. The following Restatement comment and illustration are consistent with Idaho law2 and pertinent to our resolution of the issue at hand:
d. Substantial Performance. In an important category of disputes over failure of performance, one party asserts the right to payment on the ground that he has completed his performance, while the other party refuses to pay on the ground that there has been an uncured material failure of performance. A typical example is that of the building contractor who claims from the owner payment of the unpaid balance under a construction contract. In such cases it is common to state the issue, not in terms of whether there has been an uncured material failure by the contractor, but in terms of whether there has been substantial performance by him____ If there has been substantial although not full performance, the building contractor has a claim for the unpaid balance and the owner has a claim only for damages. If there has not been substantial performance, the building contractor has no claim for the unpaid balance, although he may have a claim in restitution.
Illustration
11. A contracts to build a house for B, for which B promises to pay $50,000 in monthly progress payments equal to 85% of the value of the work with the balance to be paid on completion. When A com*742pletes construction, B refuses to pay the $7,500 balance claiming that there are defects that amount to an uncured material breach. If the breach is material, A’s performance is not substantial and he has no claim under the contract against B, although he may have a claim in restitution. If the breach is not material, A’s performance is said to be substantial, he has a claim under the contract against B for $7,500, and B has a claim against A for damages because of defects.
RESTATEMENT, supra, § 237, at 220-21 (emphasis added).
The pivotal question here is whether Ervin substantially performed under the contract. “Substantial performance” is performance which, despite deviation or omission, provides the important and essential benefits of the contract to the promisee. Gilbert v. City of Caldwell, 112 Idaho 386, 394, 732 P.2d 355, 363 (Ct.App.1987). Whether a contractor’s performance is substantial, and the defects minor or insubstantial, is a question of degree involving a factual determination. This determination turns upon circumstances such as the particular structure involved, its intended purposes, and the nature and relative expense of the repairs, as well as equitable considerations. See Eldred v. C.L. Folkman Co., 93 Idaho 131, 133, 456 P.2d 775, 777 (1969); see also Nelson v. Hazel, 91 Idaho 850, 433 P.2d 120 (1967); Mackey v. Eva, 80 Idaho 260, 328 P.2d 66 (1958); Mountain Restaurant Corp. v. Park Center Mall Assocs., 122 Idaho 261, 833 P.2d 119 (Ct.App.1992); Myers v. AO. Smith Harvestore Products, 114 Idaho 432, 757 P.2d 695 (Ct.App.1988).
In the instant case, the court recognized that while the rustic nature of a log home permits some gaps, cracks, warping and rough finish, some of the construction imperfections present in the Van Ordens’ home were excessive. However, the court found that Ervin’s breach of its express and implied warranties to build the home in a workmanlike manner was “not substantial,”3 that is, not material. In reviewing this factual determination, we give consideration to the district judge’s unique opportunity to personally view the home. The court’s findings also reflect that Ervin had completed approximately $34,827 under the contract, as compared with the $10,348 incurred for repairs. Moreover, even after the Van Ordens became aware of the problems with the workmanship, they-orally assured Ervin they would make payment for the work performed, and Ervin continued with the construction. These facts, which are supported by the evidence in the record, form a sufficient basis from which the district court properly could find that Ervin had substantially performed under the contract. Accordingly, the court correctly concluded that Ervin was entitled to recover the payment from the Van Or-dens, subject, of course, to the Van Ordens’ claim for damages.
DAMAGES
We next consider whether the court applied an appropriate measure of damages. The Van Ordens assert that the court erred by (1) arbitrarily reducing by one-half their recovery for expenses they incurred to partially repair the defects, and (2) failing to award damages for the diminution in their home’s value caused by the improperly constructed deck and roof structure and the unsealed gap between the. wall’s top log courses and the roof.
The Van Ordens contend that the court’s decision to reduce their recovery for repair costs by one-half was unwarranted under either the facts or the law. We agree. As correctly concluded by the district court, the Van Ordens’ uncured failure to make the payments due discharged Ervin’s remaining duties under the contract — justifying Ervin’s immediate withdrawal from the job site — and gave rise to Ervin’s claim for breach of contract. However, the Van Ordens’ refusal to pay did not negate their claim for damages caused by Ervin’s defective performance. As illustrated in the above excerpts from the *743Restatement, Ervin was entitled to recover the balance due under the contract,4 subject to the Van Ordens’ claim for damages. Accord Eldred, supra; Nelson, supra; Mackey, supra. The district court’s decision to reduce these damages by one-half is inconsistent with established principles of contract law and, accordingly, is reversed.
The Van Ordens additionally aver that the court erred by failing to award damages for the improper construction of the deck and roof structure or the unsealed gap between the walls and the roof — defects which the court specifically found to exist at the time Ervin left the job site. They maintain that these defects cannot be repaired without partially demolishing the home and therefore they are entitled to recover damages based on the diminution in the home’s value caused by these defects.
Where, as here, a breach results in defective construction, the injured party may recover damages based on either (1) the diminution in the market price of the property caused by the breach, or (2) the reasonable cost of remedying the defects, if that cost is not clearly disproportionate to the probable loss in value to him. Gilbert v. Tony Russell Const., 115 Idaho 1085, 1039, 772 P.2d 242, 246 (Ct.App.1989); RESTATEMENT, supra, § 348; see also Hafer v. Horn, 95 Idaho 621, 515 P.2d 1013 (1973). The “diminution in the market price” is measured as the difference between the market price that the property would have had without the defects and the market price of the property with the defects. Gilbert v. City of Caldwell, 112 Idaho at 394, 732 P.2d at 363; RESTATEMENT, supra, § 348 comment e. The injured party must prove the diminution in value caused by the other’s breach with reasonable certainty, or damages are not recoverable. RESTATEMENT, supra, § 352.
Although the record before us contains some evidence relevant to the issue of diminution in value, the district court neglected to make any findings in this regard. Because we do not deem the answer to be obvious from the record, we hold that the question should be addressed on remand. Pope v. Intermountain Gas Co., 103 Idaho 217, 225, 646 P.2d 988, 996 (1982).
PREJUDGMENT INTEREST
We next examine the propriety of district court’s award of prejudgment interest to Ervin. In Idaho, an award of prejudgment interest is allowed only where the amount of liability is liquidated or capable of ascertainment by mere mathematical process. Stoor’s Inc. v. Department of Parks and Recreation, 119 Idaho 83, 86, 803 P.2d 989, 992 (1990); Barber v. Honorof 116 Idaho 767, 770, 780 P.2d 89, 92 (1989). In order for interest to be calculated from the date of breach of contract, the amount upon which the interest is to be based must have been mathematically and definitely ascertainable. Barber, 116 Idaho at 770, 780 P.2d at 92; Taylor v. Herbold, 94 Idaho 133, 483 P.2d 664 (1971); Burt v. Clarendon Hot Springs Ranch, Inc., 117 Idaho 1042, 793 P.2d 715 (Ct.App.1990).
As explained above, Ervin’s substantial performance under the contract entitled it to recover the unpaid balance for the work completed, less any damages caused by its defective performance. See Eldred, supra; Nelson, supra. Although the amount of the unpaid contract was certain and ascertainable at the time of breach, the amount of the offset for Ervin’s defective workmanship was not definite until judicially determined at trial. Until that time, the amount of the Van Ordens’ liability to Ervin was not mathematically ascertainable, and prejudgment interest should not have been allowed. Therefore, the decision of the district court to award prejudgment interest is reversed.
NEGLIGENCE
The Van Ordens also challenge the district court’s failure to find Ervin liable on their negligence claim. We observe, however, that negligence was but an alternative *744basis of recovery for the same economic loss alleged under the breach of warranty claim. Because we uphold the district court’s finding of liability under the warranty theory, we need not decide whether it also should have found Ervin negligent.
ATTORNEY FEES AND COSTS
Finally, we are asked to review the district court’s award of costs and attorney fees to Ervin. Although we find no error in the trial court’s application of the relevant law in determining costs and fees, our decision to vacate the judgment and remand the case for an adjustment of the parties’ respective damages awards — factors bearing on the question of prevailing party5 and on the amount of a reasonable attorney fee6 — requires that we also vacate the order awarding costs and attorney fees for a redetermination on remand.
CONCLUSION
For the reasons stated above, we vacate the judgment and remand the case to the district court for a recomputation of the parties’ respective damages consistent with this opinion, and to enter a single judgment in favor of the party entitled to the larger judgment. I.R.C.P. 54(b). No costs or attorney fees awarded on appeal.
SWANSTROM and SILAK, JJ., concur.. What is sometimes referred to as "failure of consideration” in other cases and statutes is referred to here, as in the Restatement, as "failure of performance” to avoid confusion with the absence of consideration. See, e.g., I.C. § 28-3-408; World Wide Lease, Inc. v. Woodworth, 111 Idaho 880, 884, 728 P.2d 769, 773 (Ct.App.1986).
. See, e.g., Hunt Bros. Const. v. Wolcott, 99 Idaho 241, 580 P.2d 418 P.2d (1978); Eldred v. C.L. Folkman Co., 93 Idaho 131, 456 P.2d 775 (1969); Nelson v. Hazel, 91 Idaho 850, 433 P.2d 120 (1967); Gilbert v. City of Caldwell, 112 Idaho 386, 732 P.2d 355 (Ct.App.1987); Aldape v. Lubcke, 107 Idaho 316, 688 P.2d 1221 (Ct.App. 1984).
. We note that such findings generally are referred to in terms of whether a parly had substantially performed under the contract, or the correlative finding of whether its breach was material. However, the district judge’s meaning here is plainly understood, that is, that Ervin’s breach was not material, and therefore it had substantially performed under the contract.
. The contract expressly permitted the Van Or-dens to terminate the contract at anytime by paying Ervin for the work completed. Under this arrangement, Ervin could not recover the entire contract price, but only damages based on the percentage of work completed under the contract.
. Idaho Rule of Civil Procedure 54(d) provides that in determining which party is the prevailing party, "the trial court shall in its sound discretion consider the final judgment or the result of the action in relation to the relief sought by the respective parties____’’
. Idaho Rule of Civil Procedure 54(e)(3)(G) requires the court to consider, as a factor in determining the amount of a reasonable attorney fee, "[tjhe amount involved and the results obtained.”