D contracted to build a house for P. P agreed to pay D a total of $344,000: $294,000 in cash as the construction progressed, and $50,000 by a promissory note secured by a purchase money mortgage. On the date of the transfer of title in April 1981, P was unable to move into the house because D had not completed various items of construction. The parties then executed a supplemental agreement and reduced the total contract price by $4000 to $340,000. The parties also 'annulled' the original note and P agreed to execute a substitute note and purchase money mortgage in the amount of $43,000, to be held in escrow along with a $3000 cash payment by Ps pending D's completion of certain specified items of construction. In July 1981, P moved into the house. The escrowed cash and documents were released leaving an unpaid balance of $43,000 under the contract. Some of the items of construction specified in the supplemental agreement, however, remained incomplete. P also discovered numerous defects in the structure and substructure of the house. D refused to make repairs and P then refused to make payments on the mortgage. P sued D alleging that D had not substantially performed the contract and seeking damages for breach of contract. P commenced the second underlying action to foreclose the mortgage alleging that P had defaulted in payment. The referee found that D had breached the contract by failing to render substantial performance. The referee awarded P $73,068.75 in damages measured by the cost of repairing the construction defects. The referee also found in favor of P on D's foreclosure on the ground that D's failure of substantial performance defeated his right to recover the balance of the contract price and hence his right to foreclose the mortgage. D appealed to the Appellate Court, which affirmed. D appealed.