
103 P.3d 440 (2004)
140 Idaho 827
William "Bill" BARRY dba Quality Interiors, Plaintiff-Respondent,
v.
PACIFIC WEST CONSTRUCTION, INC., an Idaho corporation, Defendant-Appellant.
No. 30105.
Supreme Court of Idaho, Pocatello, September 2004 Term.
December 1, 2004.
*442 Wright, Wright & Johnson, PLLC, Idaho Falls, for appellant. Steven J. Wright argued.
Lowell N. Hawkes, Pocatello, for respondent.
SCHROEDER, Chief Justice.
William "Bill" Barry, d/b/a/ Quality Interiors (Quality), sued Pacific West Construction, Inc. (Pac-West) for payment for construction services rendered by Quality to Pac-West. Following trial the district court entered a *443 judgment in favor of Quality for $52,410.97, plus accrued interest, costs and attorney fees. Pac-West appeals.

I.

FACTUAL AND PROCEDURAL BACKGROUND
On December 3, 2001, the Intermountain Contractors publication advertised for bids for work on a number of projects, including a 15-bed mental health addition to the Bannock Regional Medical Center ("BRMC"). Some projects listed on the same page as the BRMC project were specifically identified as "Public Works License" jobs, meaning that bidders on those projects must hold a public works license issued pursuant to Idaho's Public Works Contractors License Act ("PWCLA"). I.C. § 54-1901 et seq. The BRMC project was not identified as a "Public Works License" job on that page. However, the BRMC project was "public works construction" as defined by the PWCLA. In addition, the "Supplementary Instructions to Bidders" indicated that all bidders on all projects listed in the advertisement must "hold current licenses as public works contractors in the State of Idaho."
Bill Barry, on behalf of Quality, submitted an identical bid to all general contractors listed in the advertisement on two specifications, Section 09260 and Section 09511. The total amount of the bid was $93,565.
Pac-West was hired as the general contractor for the project. Alex Jack, the BRMC Project Manager for Pac-West, contacted Quality and offered it the job. Pac-West maintains that it believed an additional section, Section 09111, was part of Quality's bid. Accordingly, Pac-West claims it was hiring Quality to perform the work for Sections 09260, 09511, and 09111.
Pac-West sent a Proposed Subcontract to Quality. The contract identified Sections 09260, 09511, and 09111 as the work to be performed by Quality. Barry left for vacation and his partner, Robert Figueroa, and a crew commenced work on February 1, 2001. When Barry returned, he signed the Proposed Subcontract but never delivered it to Pac-West. Barry contacted Jack and informed him that the subcontract contained a section that Quality did not bid. Barry offered to do the Section 09111 work for cost plus 10%, but Jack persisted in his belief that this section was included in Quality's original bid price.
On March 8, Jack asked Barry if Quality had a public works license. Barry acknowledged that it did not. Jack stated that Quality would have to continue its work as Pac-West employees. Barry agreed and advised his employees of the arrangement. Quality continued its work under the umbrella of Pac-West's public works license.
Barry testified that the following week Jack had a conversation with him about making Quality's lack of a public works license problem "go away" if Quality would perform the Section 09111 work as part of its original bid price. When Quality refused to do the work, Pac-West turned its men away from the job site. Pac-West claims it was only attempting to get Quality to perform the work that Pac-West believed was included in its bid price. At the time Quality was turned away it would have taken about two more weeks to complete the work on Sections 09260 and 09511.
Quality filed suit on June 7, 2002, claiming breach of contract and unjust enrichment. Quality also filed a claim against Jack individually for civil extortion. The civil extortion claim was dismissed on summary judgment. After the trial on the contract claims, the district court held that a contract had been formed between the parties for work on Sections 09260 and 09511, the job "[Quality] had bid." The district court determined that Quality breached the contract because it did not have a public works license but found that Pac-West was estopped from asserting its breach of contract claim because it attempted to use Quality's lack of a license as "leverage" to get Quality to perform the Section 09111 work at no additional cost. The district court held that Pac-West breached the contract by turning away Quality's crew from the worksite.
Quality's damages figure was arrived at by taking the total amount of the bid ($93,565.00) and subtracting the estimated price *444 for the work remaining after Quality was turned away from the worksite ($28,088.00), and subtracting amounts for credits, additional work requested and interest. The district court awarded Quality the amount it requested, $52,410.97, plus interest, costs and attorney fees. With respect to the civil extortion claim against Jack, the district court determined that Alex Jack was the "prevailing party" on the civil extortion claim and entitled to his costs. However, Jack presented evidence of only one cost, $36.50 for mileage to Pocatello. The court held that it could not award Jack this cost because "[t]here is no reference to the date of the mileage claim or for whom it is claimed." In regards to Jack's attorney fees, the court held that because the claim against him was a tort there was no basis for awarding him fees.
This appeal followed. Pac-West maintains that the district court erred in concluding the parties formed a contract when there was no meeting of the minds as to the scope of the work and in finding that Pac-West awarded Quality the "work it had bid." Pac-West also claims that the district court erred in allowing Quality to recover even though it found that Quality had breached the contract and erred in allowing Quality the benefit of the bargain, including lost profits, of an unenforceable contract. Further, Pac-West maintains that the district court erred in refusing to consider Pac-West's damages and in awarding Quality attorney fees. In addition, Alex Jack appeals the district court's denial of his costs and attorney fees incurred in defending the civil extortion claim.

II.

STANDARD OF REVIEW
The district court's findings of fact are reviewed to determine whether the evidence supports the findings of fact, and whether the findings of fact support the conclusions of law. Electrical Wholesale Supply Co., Inc. v. Nielson, 136 Idaho 814, 820, 41 P.3d 242, 248 (2001). In a court-tried case, the findings of fact are liberally construed on appeal in favor of upholding the judgment entered. Id. If the findings of fact are based on substantial evidence, even where that evidence is conflicting, they will not be overturned on appeal. Id. This court exercises free review over the lower court's conclusions of law. Mutual of Enumclaw v. Box, 127 Idaho 851, 852, 908 P.2d 153, 154 (1995).

III.

EVIDENCE SUPPORTS THE DISTRICT COURT'S FINDING THAT A CONTRACT WAS FORMED BETWEEN QUALITY AND PAC-WEST FOR QUALITY TO PERFORM THE WORK ON SECTIONS 09260 AND 09511
The district court determined that the parties entered into a preliminary agreement for Quality to perform the work on Sections 09260 and 09511. There are facts in the record that support this finding. A formal written contract was contemplated between the parties, but the fact that one was not executed is not fatal to the agreement. The district court held that Quality and Pac-West were bound by the preliminary agreement, relying on the principle articulated in Miller Constr. Co. v. Stresstek that where "the parties act under the preliminary agreement or receive benefits thereunder, they will be held to be bound notwithstanding the fact that a formal contract has never been executed." 108 Idaho 187, 189, 697 P.2d 1201, 1203 (Ct.App.1985) (quoting Elliott v. Pope, 42 Idaho 505, 511, 247 P. 796, 797 (1926)). The preliminary agreement consisted of Quality's bid on Sections 09260 and 09511 and Pac-West's acceptance of that offer by offering Quality the job "it had bid." The parties acted pursuant to that agreement. Quality did considerable work and Pac-West paid some amounts to Quality.
In order for a contract to be formed there must be a meeting of the minds. Inland Title Co. v. Comstock, 116 Idaho 701, 703, 779 P.2d 15, 17 (1989). A meeting of the minds is evidenced by a manifestation of intent to contract which takes the form of an offer and acceptance. Id. The "meeting of the minds" must occur on all material terms to the contract. Dursteler v. Dursteler, 108 Idaho 230, 233-34, 697 P.2d *445 1244, 1247-48 (Ct.App.1985). The scope of the work to be performed is a material term of a construction contract. C.H. Leavell & Co. v. Grafe & Assoc., 90 Idaho 502, 512, 414 P.2d 873, 877 (1966).
In C.H. Leavell, the trial court determined that there was never a meeting of the minds between the parties on the scope of the work to be performed by the subcontractor, and no enforceable contract was formed. Id. at 512, 414 P.2d at 877. This case differs from C.H. Leavell in that there is evidence to support the district court's finding that there was a meeting of the minds between Quality and Pac-West on the work specified in Sections 09260 and 09511. An offer was made by Quality to perform the work in Sections 09260 and 09511. Pac-West accepted this offer. There was never a "meeting of the minds" on Section 09111, but there is evidence that Pac-West defined the scope of the work and that the scope of the work was limited to that which was included in Sections 09260 and 09511. There is evidence supporting the district court's finding that the scope of the work and the other terms necessary for contract formation were agreed upon and that the parties acted pursuant to that agreement.

IV.

QUALITY AND PAC-WEST'S CONTRACT IS ILLEGAL BECAUSE IT VIOLATES I.C. § 54-1902, WHICH REQUIRES CONTRACTORS PERFORMING "PUBLIC WORKS CONSTRUCTION" TO HOLD A PUBLIC WORKS LICENSE, A REQUIREMENT QUALITY FAILED TO MEET
The parties did not raise the issue of illegality in their pleadings or at trial, and the district court did not specifically determine the effect of illegality in its Findings of Fact and Conclusions of Law. However, this Court may raise the issue of illegality sua sponte. Quiring v. Quiring, 130 Idaho 560, 566, 944 P.2d 695, 701 (1997). In fact this Court has a duty to raise the issue of illegality. Id.; see also Trees v. Kersey, 138 Idaho 3, 6, 56 P.3d 765, 768 (2002).
Idaho Code § 54-1901(a) defines a "public works contractor" as "any person who, in any capacity, undertakes, or offers to undertake, or purports to have the capacity to undertake any construction, repair or reconstruction of any public work...." The BRMC project was "public works construction" as defined by I.C. § 54-1901(c). Both Pac-West and Quality fit within the definition of a "public works contractor" under I.C. § 54-1901(a). I.C. § 54-1902 states that:
"It shall be unlawful for any person to engage in the business or act in the capacity of a public works contractor within this state without first obtaining and having a license issued pursuant to the provisions of this chapter by the administrator of the division of building safety, unless such person is particularly exempted as provided in this chapter."
Quality does not fit within any of the exemptions delineated in I.C. § 54-1903. Therefore, it was required to have a public works license. The fact that Quality did not have the requisite license renders its contract with Pac-West illegal, because the contract constituted an agreement to perform an illegal act.
The Court will not enforce an illegal contract. Quiring, 130 Idaho at 568, 944 P.2d at 703. Illegal contracts are void, and generally the Court will "leave the parties where it finds them." Id.; Trees, 138 Idaho at 9, 56 P.3d at 771; Kunz v. Lobo Lodge, Inc., 133 Idaho 608, 611, 990 P.2d 1219, 1222 (Ct.App.1999). This Court has stated that, "the rationale for leaving the parties where the law finds them is premised on the notion that both parties are equally at fault." Trees, 138 Idaho at 9, 56 P.3d at 771. When the Court "leaves the parties where it finds them," it denies recovery to either party. Morrison v. Young, 136 Idaho 316, 319, 32 P.3d 1116, 1119 (2001); Kunz, 133 Idaho at 612, 990 P.2d at 1223.
The contract between Quality and Pac-West is illegal and is, therefore, unenforceable. The question remains whether either party is entitled to its damages outside the existence of a legal contract.


*446 V.

QUALITY IS ENTITLED TO RECOVER UNDER A THEORY OF UNJUST ENRICHMENT
This Court has recognized situations in which relief to a party to an illegal contract is warranted to avoid unduly harsh results. In such instances, the Court has awarded damages based on the rationale that, although illegal contracts are unenforceable as a matter of public policy, circumstances arise where denying a party relief would frustrate the public interest more than "leaving the parties where they lie." This Court has stated that, "[b]arring the strict application of the illegality doctrine, the central focus must be whether the ends of the law will be furthered or defeated by granting the relief requested." Trees, 138 Idaho at 9, 56 P.3d at 771.
The Court has recognized an exception to the unenforceability of an illegal contract where the parties are not "in pari delicto," granting relief to the innocent party. McShane v. Quillin, 47 Idaho 542, 277 P. 554, 559 (1929). In addition, this Court has recognized specific exceptions where fraud, undue influence, or duress are present, Trees, 138 Idaho at 10, 56 P.3d at 772; where the plaintiff is innocent and the agreement does not violate a statute, Williams v. Cont'l Life & Acc. Co., 100 Idaho 71, 73, 593 P.2d 708, 710 (1979); and, in the case of a void insurance contract, where unenforceability would "defeat the purpose for which a statute has been enacted." Martinez v. Idaho Counties Reciprocal Mgmt. Program, 134 Idaho 247, 252-53, 999 P.2d 902, 907-08 (2000). In McFall v. Arkoosh, 37 Idaho 243, 215 P. 978, 979 (1923) (quoting 6 Ruling Case Law 829, § 220) the Court articulated the public policy interest that may motivate the award of damages to a party to an illegal contract. The Court stated that:
Public policy, it must be borne in mind, lies at the basis of the law in regard to illegal contracts, and the rule is adopted, not for the benefit of the parties, but of the public. It is evident, therefore, that cases may arise even under contracts of this character, in which the public interests will be better promoted by granting than by denying relief, and in such the general rule must yield to this policy. Hence, even between parties in pari delicto, relief will sometimes be granted if public policy demands it.
The circumstances of this case do not squarely fit within one of the specific exceptions described above. The State is not a party to this case and has not sought to deny Pac-West payment for employing a non-licensed subcontractor. Denying Quality any recovery for the work it performed on the BRMC project, while Pac-West retains the benefit of Quality's work (and has been paid by the hospital owners for its work), is a harsh result, particularly where the public entity has not sought any remedy for the breach of the public policy set forth in I.C. § 54-1901(a).
Courts in other jurisdictions are divided between those that permit an unlicensed contractor to pursue a claim for restitution, and those that strictly adhere to the principle that the court will leave the parties to an illegal contract where it finds them, denying any form of recovery. 66 Am.Jur.2d Restitution and Implied Contracts § 66 (1973); Francis M. Dougherty, Annotation, Failure of Building and Construction Artisan or Contractor to Procure Business or Occupational License as Affecting Enforceability of Contract or Right of Recovery for Work Done-Modern Cases, 44 A.L.R.4th 271, 332-37 (1986). For example, the Maryland Court of Appeals refused to award damages to an unlicensed contractor because "to permit a recovery on a quantum meruit would defeat and nullify the statute." Harry Berenter, Inc. v. Berman, 258 Md. 290, 296, 265 A.2d 759, 763 (1970). That court recognized that the result permitted the recipient of the work to retain the benefit without having to pay for it, but because the statute was designed to protect the public the court would not give any recovery to a party that violated it. Id. The Maryland court focused on the effect on the public interest, rather than on the defendant's retention of a benefit.
On the other hand, the Supreme Court of Tennessee held that an unlicensed contractor was able to sue a licensed contractor for *447 which it had performed work under a quantum meruit theory. Gene Taylor & Sons Plumbing Co., Inc. v. Corondolet Realty Trust, 611 S.W.2d 572, 576 (1981). The court reasoned that since the statute making the contract illegal was designed to protect the public, "[t]he policies that bar recovery against a member of the general public do not apply in suits against licensed professionals in the same business." Id. at 575-76. See also 66 Am.Jur.2d Restitution and Implied Contracts § 66 (1973 & Supp.1996) for additional cases illustrating the split among jurisdictions between those allowing recovery and those denying recovery under similar facts.
Though some courts do not differentiate between the measure of recovery under unjust enrichment and quantum meruit, this Court has carefully done so. 66 Am.Jur.2d Restitution and Implied Contracts § 66 (1973 & Supp.1996). In Peavey v. Pellandini, 97 Idaho 655, 658, 551 P.2d 610, 613 (1976), this Court stated that quantum meruit is the appropriate recovery under a contract implied in fact. A contract implied in fact exists where there is no express agreement but the parties' conduct evidences an agreement. Id. (quoting Continental Forest Prod., Inc. v. Chandler Supply Co., 95 Idaho 739, 518 P.2d 1201 (1974)). Unjust enrichment, or restitution, is the measure of recovery under a contract implied in law. Id. A contract implied in law, or quasi-contract, "is not a contract at all, but an obligation imposed by law for the purpose of bringing about justice and equity without reference to the intent of the agreement of the parties, and, in some cases, in spite of an agreement between the parties." Id. Recovery under a quantum meruit theory is measured by "the reasonable value of the services rendered or of goods received, regardless of whether the defendant was enriched." Erickson v. Flynn, 138 Idaho 430, 434-35, 64 P.3d 959, 963-64 (Ct.App.2002). Recovery under an unjust enrichment theory, on the other hand, is limited to the amount by which the defendant was unjustly enriched. Id. at 434, 64 P.3d at 963. Here, the contract between Quality and Pac-West was express, but failed because of illegality. Any recover by Quality is limited to restitution, and Quality must prove that Pac-West was unjustly enriched.
The district court awarded Quality damages based on breach of contract. Thus, Quality not only recovered the value of the work it performed, but it also recovered its profit on that work. As this Court indicated in Quiring v. Quiring, "a party to an illegal contract cannot ask the Court to have his illegal objects carried out." 130 Idaho at 568, 944 P.2d at 703. If Quality is entitled to its lost profits for the work it performed on the BRMC project, the illegal agreement is in effect enforced. Any damages Quality recovers are in the form of restitution, limiting its recovery to the amount by which Pac-West was unjustly enriched. This may inure to the benefit of Pac-West, but that result cannot be avoided if the public policy behind the unenforceability of illegal contracts is to be preserved.
Pac-West argues that Quality failed to prove the elements of unjust enrichment and should be denied relief. In Blaser v. Cameron, the Court of Appeals indicated that a party seeking recovery under an unjust enrichment theory must present evidence not only of the value of the services it rendered, but also "the amount of the benefit which, if retained by the [defendant], would result in their unjust enrichment." 121 Idaho 1012, 1017, 829 P.2d 1361, 1366 (Ct.App.1991). The Court of Appeals affirmed the district court's finding that the plaintiff failed to establish a claim for unjust enrichment because it did not present evidence of the amount by which the defendant was unjustly enriched. Id.
In this case Quality calculated its damages by subtracting from its total bid price the value of the work it was not permitted to complete. The damage figure it arrived at, $52,416.96, represents the value of the work it had performed plus the profit related to that work. That award is vacated and the case remanded for a determination of the recovery, if any, to which Quality is entitled under the theory of unjust enrichment. The district court should make its determination based on the evidence presented at trial that has taken place without the further presentation of evidence. Whether there is an adequate *448 record for Quality to meet its burden of proving unjust enrichment to Pac-West is for the district court to determine.

VI.

NEITHER PARTY IS ENTITLED TO ATTORNEY FEES BECAUSE THE CONTRACT WAS ILLEGAL, AND THERE CAN BE NO "PREVAILING PARTY" IN AN ILLEGAL TRANSACTION EVEN WHERE SOME RECOVERY MAY BE ALLOWED
Both Quality and Pac-West seek attorney fees under I.C. § 12-120(3), which permits the "prevailing party" to recover its reasonable attorney fees in actions on contracts or "commercial transactions." The term "commercial transactions" is broadly defined to include "all transactions except transactions for personal or household purposes." I.C. § 12-120(3)(2003). In Intermountain Forest Mgmt., Inc. v. Louisiana Pacific Corp., this Court held that the prevailing party was entitled to attorney fees, despite the fact that a contract had never been formed because of a lack of mutual assent to be bound. 136 Idaho 233, 238, 31 P.3d 921, 926 (2001). The Court reasoned that a party alleging the existence of a contractual relationship was entitled to fees as a prevailing party though "no liability under contract was established." Id.
However, this Court in Trees stated that, where the alleged contract or commercial transaction is illegal, "neither party should be permitted to claim the benefit of I.C. § 12-120(3)." Trees, 138 Idaho at 12, 56 P.3d at 774; see also Kunz, 133 Idaho at 612, 990 P.2d at 1223. In this case there was an illegal contract. Both parties had the opportunity to determine the deficiency that made the contract illegal. Neither is entitled to attorney fees.

VII.

ALEX JACK IS NOT ENTITLED TO HIS COSTS AND ATTORNEY FEES
Jack is not entitled to costs and fees he incurred in defending the civil extortion claim. The district court did not abuse its discretion by denying Jack his costs where he did not provide the court with sufficient information to determine whether such costs were necessary under I.R.C.P. 54(d)(1)(D). With respect to Jack's attorney fees, the district court properly denied Jack's request where the claim against him sounded in tort and was not pursued frivolously by Quality.

VIII.

CONCLUSION
The case is remanded to the district court for a determination of the extent of recovery, if any, by Quality for unjust enrichment to Pac-West based upon the existing record. Neither party is entitled to costs or attorney fees on appeal or before the district court.
Justice TROUT, Justices KIDWELL, EISMANN and BURDICK, concur.
