
617 P.2d 206 (1980)
Joe M. WELLING and Freda Welling, Appellants,
v.
AMERICAN ROOFING AND SHEET METAL COMPANY, INC., an Oklahoma Corporation, Appellee.
No. 50528.
Supreme Court of Oklahoma.
September 16, 1980.
Curtis L. Culver, Tulsa, for appellants.
Ken Ray Underwood, Tulsa, for appellee.
*207 SIMMS, Justice:
Homeowner plaintiffs appeal from a judgment on a counterclaim foreclosing a lien on their property in favor of defendant *208 roofer. Early in 1975, plaintiff contracted with Mike Wells, a general contractor, to do a room addition to their home. Wells contacted defendant to obtain a price quotation for re-roofing the entire house, including the new room addition. The price was given to Wells to be $740 for the roof on the new addition, and $3,900 for the rest of the house. Wells told defendant's agent that he would have to get plaintiffs' approval. Defendant's agent took some shingle samples to plaintiffs' house and he and the plaintiffs discussed the re-roofing project. Defendant agreed with plaintiffs to lower the price from $3,900 to $2,700 in exchange for plaintiffs tearing off the old roof themselves. Defendant thereafter furnished the roofing material and performed the labor. Because of defendant's failure to adequately seal (or "Dry-in") the roof during construction, plaintiff refused to pay for the roofing and claimed rain damage to their home and contents in the sum of $1,188.46.
Defendant filed a sub-contractor's lien on the house January 12, 1976, in the amount of $3,440 ($740 plus $2700). Plaintiffs brought this action to set the lien aside, under 42 O.S. 1971, § 177 (amended 1977), claiming that the last material furnished or labor performed was not within 90 days before the filing of the lien. Defendant counterclaimed for foreclosure of the lien, and to recover the amount of the lien on the theory of unjust enrichment.
The trial court found that the last material furnished or labor performed was not within 90 days before the filing of the lien statement, and the filing of the sub-contractor's lien came too late. 42 O.S. 1971, § 143. The court further found, however, that the defendant was really a contractor to the $2,700 re-roofing portion, and established a lien for that amount, as the statement was filed within the 120 days allowed a contractor, 42 O.S. 1971, § 142 (amended 1977). The trial court allowed plaintiffs' setoff of $1,188.46 for rain damage, and ordered foreclosure of the lien in the sum of $1,511.54, with an in personam judgment against plaintiffs for a like amount, plus interest, attorney fees and court costs.
Plaintiffs claim the trial court's finding that defendant was a contractor is clearly against the weight of the evidence. A sub-contractor is one who has entered into a contract, express or implied, for the performance of an act with a person who has already contracted for its performance. Dolese Bros. Co. v. Andrecopulas, 113 Okl. 18, 237 P. 844 (1925); Rogers v. Crane Co., 180 Okl. 139, 68 P.2d 520 (1937). The inquiry in this case is twofold. First, whether Wells, the contractor, had a contract with the plaintiffs, the homeowners, to do the $2,700 re-roofing portion, and second, if Wells then contracted with the defendant to do the job. If both questions are answered affirmatively then any subsequent discussion between plaintiffs and defendant could not operate to change defendants legal status of sub-contractor.
The trial court found defendant to be a contractor to the $2,700 portion based upon plaintiff's own "uncontradicted" testimony, put forth after the close of defendants case; that Wells' contract with the plaintiffs was limited to the $740 portion consisting of a new roof for the new room addition and did not extend to the re-roofing of the rest of the house.
At issue is the discussion had between plaintiffs and defendant to lower the cost of the re-roofing job in exchange for the plaintiffs tearing off their own roof. The price was lowered, for this portion, from $3,900 to $2,700. Defendant claims it is the contractor to this part of the job. Defendant's agent went to the plaintiffs' home to enable plaintiffs to choose a shingle style and color. During this meeting the plaintiffs discovered they could save $1,200 by tearing off the old roof themselves. This discussion does not establish the existence of a separate contract between plaintiffs and defendant for that portion of the roofing contract. Moreover, it does nothing to refute the persuasive evidence showing that the entire roofing contract was let through Wells, as general contractor for plaintiffs.
The affidavit of defendants' agent, Mayo Hemperly, specifically states that the re-roofing agreement was reached between defendant *209 and Wells, as plaintiffs' contractor. Wells initially contacted defendant about doing the job. Wells was subsequently given approval to let the contract to the defendant. All of defendant's invoices were submitted for payment to Wells as plaintiffs' contractor. Plaintiff testified he entered into the agreement with the defendant "through my contractor", and that the original contract and all business arrangements were made through his contractor and subsequently approved by him.
The pleadings clearly show that the defendant considered itself a sub-contractor to all portions of the roofing contract. Defendant's own lien statement named itself as sub-contractor and Wells as contractor. Defendant's answer specifically admitted that it was a sub-contractor. Defendant's counterclaim stated that the work was performed at the special request of Wells, as contractor. Further, the trial court made a pre-trial order that the only issue remaining to be determined at trial is whether materials were furnished or labor performed within the terms of the contract on October 27, 1975, within the 90 days preceding the filing of the lien statement allowed a sub-contractor.
This Court has held that the sub-contractor's lien statute should not receive such a narrow construction as to exclude from its application persons or classes who are intended to be placed within its protection. Ryndak v. Seawell, 13 Okl. 737, 76 P. 170 (1904); Standard Accident Insurance Co. v. Basolo, 180 Okl. 261, 68 P.2d 804 (1937).
The clear weight of the evidence shows that Wells was the person the plaintiffs hired to do the entire roofing job, and that Wells subsequently sub-contracted it to the defendant. Even if the trial court was correct in finding that Wells original contract was limited to construction of the new room addition only (including the roof for that portion), the evidence shows at least a subsequent implied contract between the plaintiffs and Wells for the re-roofing of the rest of the house. See: Tulsa Fuel & Manuf. Co. v. Gilchrist Drilling Co., 79 Okl. 82, 190 P. 399 (1920). Ray F. Fischer Co., Inc. v. Loeffler-Green Supply Co., Okl., 289 P.2d 139 (1955).
We hold that the trial courts' finding that the defendant was a contractor to the $2,700 portion is clearly against the weight of the evidence, which, as a whole, shows that the defendant was in fact a sub-contractor to the entire roofing project. Ryndak v. Seawell, supra; Hall v. North Plains Concrete Service, Inc., Okl., 425 P.2d 941 (1966); Standard Accident v. Basolo, supra; Rogers et al. v. Crane Co., 180 Okl. 139, 68 P.2d 520 (1937).
Since the last material furnished or work performed was not within 90 days of the filing of the lien statement, the judgment foreclosing the lien must be set aside. Even had the statement been timely filed, foreclosure would be error since the contractor was not made a party to defendant's counterclaim for foreclosure. 42 O.S. 1971, § 173 (amended 1977).
In light of the above disposition, it is unnecessary to address plaintiffs' contention that the trial court erred by making a finding of fact on an issue not raised by the pleadings to change the nature of the transaction. 12 O.S. 1971, § 317. Similarly, we need not address plaintiffs' claim that the Oklahoma mechanic and materialman's lien statutes are unconstitutional.
We must now turn to the remainder of the judgment below. There is no error in plaintiffs' recovery of $1,188.46 for unworkmanlike construction. Defendants' in personam recovery of $1,511.54 plus interest, attorney fees and court costs must be affirmed.
Defendant's in personam recovery was allowed on its counterclaim for unjust enrichment. However, defendant's recovery was factually predicated on a quasi-contract theory. A quasi-contract is an obligation implied by law on the ground that it is dictated by reason and justice. First Nat. Bank of Okmulgee v. Matlock, et al., 99 Okl. 150, 226 P. 328 (1924). In the case at bar, defendants were clearly entitled to recover for their service on their theory. The measure of damages in a quasi-contract *210 action is the amount which will compensate the party aggrieved for the detriment proximately caused thereby, and, if the obligation is to pay money, the detriment caused by the breach in the amount due by the terms of the obligation. Monarch Refineries, Inc. v. Union Tank Car Co., 193 Okl. 110, 141 P.2d 556 (1943). In Monarch, supra, the plaintiff, in the business of renting tank cars, was allowed to recover damages for the use of his car, without consent, based upon his regular rates established in good faith, even though there was evidence that the prevailing rental rates in the vicinity for like cars were somewhat less than the plaintiffs regular rates.
In our case, the defendant was in the business of building roofs, and there is no evidence that his original price quotation was set in bad faith. We hold, therefore, that the defendant should recover the amount prayed for in its counterclaim of unjust enrichment, excepting the $740 which the trial court denied and from which denial no appeal was taken.
Finally, we turn to the question of attorney fees. The trial court awarded defendant attorney fees as it was the prevailing party on its counterclaim for unjust enrichment. This was a proper application of 12 O.S. 1971, § 936, because whether the action is based on quasi-contract or implied contract, the action in any event is ex contractu. Monarch Refineries, Inc. v. Union Tank Cars, supra; Berry v. Barbour, Okl., 279 P.2d 335 (1954). However, plaintiffs were also entitled to recover a reasonable attorney fee, as they were the parties for whom judgment was rendered on the lien claim. 42 O.S. 1971, § 176. Under such circumstances, plaintiffs should recover their attorney fees from defendant, and defendant should recover its attorney fees from the plaintiffs. Walls v. Russell, Okl. App., 519 P.2d 936 (1974). Because there was no evidence in the trial court, the case should be remanded to determine the reasonable amount of plaintiffs' attorney fees.
In short, plaintiffs are entitled to have the lien discharged. Defendant is entitled to an in personam judgment of $2,700.00 less plaintiffs' setoff of $1,188.46 for unworkmanlike construction, or a total judgment for defendant in the amount of $1,511.54. The trial court's award of attorney fee is ordered modified to $800.00, to be taxed as costs in the action. The cause is remanded for a determination of plaintiffs' just and reasonable attorney's fees, and defendant's recovery should be reduced by that amount.
REVERSED IN PART, AFFIRMED IN PART, AND REMANDED WITH DIRECTIONS.
LAVENDER, C.J., and WILLIAMS, HODGES, BARNES, DOOLIN and HARGRAVE, JJ., concur.
IRWIN, V.C.J., and OPALA, J., concur in part and dissent in part.
