#### PAUL D. SHAPERO *v.*FRANK MERCEDE, JR.

(AC 21230)

Schaller, Dranginis and Bishop, Js.1

Argued February 18

officially released June 17, 2003

*498*Brenden P. Leydon,*for the appellant (plaintiff).

*Anthony J. LaBella,*with whom, on the brief, was *Neal L. Moskow,*for the appellee (defendant).

1

 The original panel of judges included Judge Schaller, Judge Mihalakos and Judge O’Connell. Due to a change in the composition of the court by the time the remand was issued, the appeal was reargued before a new panel.

*Opinion*

DRANGINIS, J.

This case returns to us on remand from our Supreme Court. *Shapero*v. *Mercede,*262 Conn. 1, 11, 808 A.2d 666 (2002). In reversing the prior decision of this court,2 our Supreme Court remanded the case to us “for consideration of the plaintiffs claim on cross appeal regarding the propriety of the $5000 [credit].” Id. Before turning to the merits of the claim that we must consider on remand, we first set forth some of the relevant facts and procedural history of this case.

“In May, 1995, the defendant [Frank Mercede, Jr.] hired the plaintiff [Paul D. Shapero], an attorney, to represent him in a tax appeal to reduce the assessment *499on two commercial properties owned by the defendant.3 On May 17, 1995, the defendant paid the plaintiff a $5000 retainer and entered into an agreement to pay the plaintiff on a contingency fee basis. In May, 1997, the defendant discharged the plaintiff and hired substitute counsel on an hourly basis. Within four months, substitute counsel had successfully concluded the defendant’s appeal. . . . The defendant paid substitute counsel $15,000 for services rendered in resolving the matter.

“On February 8, 1998, the plaintiff filed an action against the defendant to recover legal fees under causes of action sounding in quantum meruit, breach of contract, unjust enrichment, violation of the Connecticut Unfair Trade Practices Act, General Statutes § 42-110a et seq., and fraud. The defendant thereafter alleged two special defenses: (1) that the plaintiff was paid for his work, and (2) that the plaintiff breached the standard for professional conduct within the legal community.4 On December 28, 1999, the matter was heard by [an attorney trial] referee. During the hearing, the plaintiff presented no evidence relating to the hourly rate that he charged the defendant. The plaintiff testified that he had reasonably spent 100 hours on the defendant’s case.

“On May 31, 2000, the referee filed a report recommending judgment for the plaintiff in the amount of $27,500 with $5000 credited against the retainer. The referee arrived at those figures by calculating the plaintiffs hourly rate at $275 multiplied by 100 hours. . . . On July 11, 2000, the court, *Karazin, J.,*accepted the referee’s report .... On October 2, 2000, the plaintiff *500filed a motion for articulation. In response, the court on November 6, 2000, filed a memorandum of decision upholding the referee’s findings and her crediting of the $5000 retainer against the amount of the judgment.”5 (Internal quotation marks omitted.) *Shapero*v. *Mercede,*supra, 262 Conn. 3-4.

The defendant appealed to this court, claiming, inter alia, that the trial , court “improperly (1) awarded the plaintiff damages on his claim for nonpayment of legal fees when the . . . referee . . . had found that no evidence as to the value of the plaintiffs services had been introduced at the hearing . . . .” *Shapero*v. *Mercede,*66 Conn. App. 343, 344, 784 A.2d 435 (2001), rev’d, 262 Conn. 1, 808 A.2d 666 (2002). The plaintiff made various arguments in response and also filed a cross appeal, maintaining that the court improperly permitted the defendant to obtain a credit of $5000 when the defendant had not pleaded it as a special defense or setoff. Id. We agreed with the defendant with regard to his first claim and, therefore, declined to address his other claims. Id., 346. We did not reach the plaintiffs claim *501on the cross appeal.6 Id., 353. Consequently, we reversed the court’s judgment and remanded the case with direction to render judgment for the defendant. Id.

Our Supreme Court granted the plaintiffs petition for certification to appeal; see *Shapero*v. Mercede, 258 Conn. 944, 786 A.2d 430 (2001); reversed our decision; see footnote 2; and remanded the case to this court “for consideration of the plaintiffs claim on cross appeal regarding the propriety of the $5000 [credit].” *Shapero*v. Mercede, supra, 262 Conn. 11. We conclude that the trial court properly credited the $5000 retainer amount paid by the defendant against the amount of the damages awarded to the plaintiff. Accordingly, we affirm the judgment of the trial court.

Our standard of review in cases referred to attorney trial referees is well settled. “A reviewing authority may not substitute its findings for those of the trier of the facts. This principle applies no matter whether the reviewing authority is the Supreme Court . . . the Appellate Court ... or the Superior Court reviewing the findings of . . . attorney trial referees. . . . [Attorney trial referees and factfinders share the same function . . . whose determination of the facts is reviewable in accordance with well established procedures prior to the rendition of judgment by the court.

“[B]ecause the attorney trial referee does not have the powers of a court and is simply a fact finder, [a]ny legal conclusions reached by an attorney trial referee have no conclusive effect. . . . The reviewing court is the effective arbiter of the law and the legal opinions *502of [an attorney trial referee], like those of the parties, though they may be helpful, carry no weight not justified by their soundness as viewed by the court that renders judgment. . . . Where legal conclusions are challenged, we must determine whether they are legally and logically correct and whether they find support in the facts found by the . . . referee.” (Citations omitted; internal quotation marks omitted.) *Alliance Partners, Inc.*v. *Oxford Health Plans, Inc.,*263 Conn. 191, 201-202, 819 A.2d 227 (2003).

The plaintiff claims that because the defendant did not plead a special defense or setoff regarding the $5000 credit, the court improperly accepted the referee’s recommendation to credit the $5000 retainer payment against the amount of the damages awarded to the plaintiff.7 The plaintiff does not contest the referee’s factual finding that the defendant paid him the $5000 retainer. Rather, the plaintiff maintains that the $5000 credit recommended by the referee was improper as a matter of law, as the defendant did not plead a special defense or setoff. The plaintiff argues that regardless of whether the $5000 credit is characterized as a defense of payment or as a setoff, it should have been affirma*503tively pleaded as such, in accordance with Practice Book §§ 10-50 or 10-54.8 The plaintiff contends that by crediting the $5000 retainer payment against the other damages in the absence of such an affirmative pleading by the defendant, the court improperly founded its judgment on facts or issues outside of those raised in the pleadings. We disagree.

At the outset, we note that “[p]leadings have their place in our system of jurisprudence. While they are not held to the strict and artificial standard that once prevailed, we still cling to the belief, even in these iconoclastic days, that no orderly administration of justice is possible without them.” (Internal quotation marks omitted.) *Yellow Page Consultants, Inc.*v. *Omni Home Health Services, Inc.,*59 Conn. App. 194, 200, 756 A.2d 309 (2000). The purpose of a complaint, special defense or counterclaim is to limit the issues at trial, and such pleadings are calculated to prevent surprise. See id.; *New Milford Savings Bank*v. *Roina,*38 Conn. App. 240, 244, 659 A.2d 1226, cert. denied, 235 Conn. 915, 665 A.2d 609 (1995). “It is fundamental in our law that the right of a [party] to recover is limited to the allegations in his [pleading]. . . . Facts found but not averred cannot be made the basis for a recovery. ” (Internal quotation marks omitted.) *Yellow Page Consultants, Inc.*v. *Omni Home Health Services, Inc.,*supra, 200; see also *Westfall*v. *Westfall,*46 Conn. App. 182, 185, 698 A.2d 927 (1997) (“judgment cannot be founded on a finding of facts not in issue, although they may have been shown in evidence to which no proper objection was taken”).

*504Thus, it is clear that “[t]he court is not permitted to decide issues outside of those raised in the pleadings.” *Yellow Page Consultants, Inc.*v. *Omni Home Health Services, Inc.,*supra, 59 Conn. App. 200. “It is equally clear, however, that the court must decide those issues raised in the pleadings.” *Moulton Bros., Inc.*v. *Lemieux,*74 Conn. App. 357, 361, 812 A.2d 129 (2002).

The sixth count of the plaintiffs complaint sounds in quantum meruit, and, in that count, the plaintiff himself raises facts relating to the retainer as the predicate for his claim.9 Our Supreme Court has explained that “[t]he measure of damages in quantum meruit is the value of the services rendered. . . . Quantum meruit literally means *as much as he has deserved*. . . .” (Citation omitted; emphasis added; internal quotation marks omitted.) *Shapero*v. *Mercede,*supra, 262 Conn. 7; see *Cole*v. *Myers,*128 Conn. 223, 230, 21 A.2d 396 (1941).10

*505“[Qjuantum meruit arises out of the need to avoid unjust enrichment to a party, even in the absence of an actual agreement. . . . Centered on the prevention of injustice, quantum meruit strikes the appropriate balance by evaluating the equities and guaranteeing that the party who has rendered services receives a reasonable sum for those services.” (Citations omitted; internal quotation marks omitted.) *Gagne*v. *Vaccaro,*255 Conn. 390, 401, 766 A.2d 416 (2001). Quantum meruit damages provide restitution for amounts not previously paid. See *United Coastal Industries, Inc.*v. *Clearheart Construction Co.,*71 Conn. App. 506, 511—12, 802 A.2d 901 (2002); see also *Gagne*v. *Vaccaro,*supra, 401; *Sidney*v. *DeVries,*215 Conn. 350, 351-52 n.1, 575 A.2d 228 (1990); *Burns*v. *Koellmer,*supra, 11 Conn. App. 375, 383-85, 527 A.2d 1210 (1987); 66 Am. Jur. 2d 634-36, Restitution and Implied Contracts § 38 (2001). It is axiomatic that the equitable doctrine of quantum meruit may not be invoked to permit parties to retain or to recover “undeserved windfalls.” See 27A Am. Jur. 2d 586, 588, Equity §§ 99, 102 (1996).

As previously set forth, the plaintiff specifically raised, in his complaint, facts and issues relating to the retainer. Furthermore, at the hearing before the referee, the plaintiff testified that he had entered into a retainer agreement with the defendant and introduced the agreement into evidence.11 The agreement called for *506payments to be made to the plaintiff on a contingency fee basis and for the payment of a $5000 retainer. In responding to the plaintiffs case-in-chief, the defendant took the witness stand and, over the plaintiffs objection, testified that he had paid the plaintiff the $5000 retainer.12 In addition, the defendant introduced into evidence a letter he received from the plaintiff, which recites that the defendant paid the plaintiff $5000. The defendant testified that the $5000 payment recited in the letter referred to his $5000 retainer payment.

By alleging a cause of action sounding in quantum meruit, the plaintiff asked the court to evaluate the equities and to award him a reasonable sum for services rendered to the defendant. The extent to which the plaintiff already had been paid by the defendant for the services rendered, specifically, the $5000 retainer payment, was an appropriate factor for the court to consider in determining that reasonable sum. If the court had not credited the $5000 retainer payment against the damages awarded to the plaintiff, then the plaintiff would have been paid twice for the same work: First, in May, 1995, and second, in collecting a $27,500 judgment.13 Such a double recovery of the retainer fee had not been earned by the plaintiff,14 would furnish *507the plaintiff with an undeserved windfall and would be inequitable to the defendant.

Thus, we disagree with the plaintiffs contention that the court improperly founded its judgment on facts or issues outside of those raised in the pleadings by crediting the $5000 retainer payment against the other damages. Because quantum meruit is a doctrine that provides restitution for amounts not previously paid; see *United Coastal Industries, Inc.*v. *Clearheart Construction Co.,*supra, 71 Conn. App. 511-12; it contemplates consideration of prior payments without the necessity of their having been pleaded.15 In other words, by alleging a cause of action in quantum meruit, the plaintiff asked the court to award him a reasonable sum for services rendered and for which payment had not been made previously. In fact, in the quantum meruit count of his complaint, he expressly sought to recover the reasonable value of the services he “performed . . . to [his] financial detriment.” See footnote 9.

Contrary to the plaintiffs assertions, the defendant’s failure to plead payment of the $5000 retainer either as a special defense pursuant to Practice Book § 10-5016*508or as a setoff pursuant to Practice Book § 10-5417 does not render the $5000 credit improper as a matter of law under the circumstances of this case.18 “The fundamental purpose of a special defense, like other pleadings, is to apprise the court and opposing counsel of the issues to be tried, so that basic issues are not concealed until the trial is underway. . . . Whether facts must be specially pleaded depends on the nature of those facts in relation to the contested issues.” (Citations omitted; internal quotation marks omitted.) *Bennett*v. *Automobile Ins. Co. of Hartford,*230 Conn. 795, 802, 646 A.2d 806 (1994).

In arguing that the $5000 retainer payment should have been made the subject of a special defense, the plaintiff relies on the language contained in Practice Book § 10-50, which provides in relevant part that “payment (even though nonpayment is alleged by the plaintiff) . . . must be specially pleaded . ...” In the quantum meruit count of his complaint, however, he alleged, inter alia, that “the defendant terminated the [parties’] legal fee agreement so as to avoid paying a contingent legal fee to the [p]laintiff,” and further, that “[t]he [p]laintiff is entitled to the reasonable value of *509services he performed *... to*[Ms] *financial detriment.”**19***(Emphasis added.) Because the plaintiff expressly sought recoveiy in quantum meruit for the services he “performed ... to [his] financial detriment,” the parties and the court had ample notice that an issue at trial would be the reasonable value of the services rendered by the plaintiff for which he had not been paid. Consequently, in the circumstances presented here, the defendant’s failure to plead payment of the $5000 retainer as a special defense did not preclude the court from considering the amount of that payment in its calculation of the plaintiffs award.

Furthermore, the defendant’s failure to plead payment of the $5000 retainer as a setoff does not render the $5000 credit improper as a matter of law. Setoff is the “right to cancel or offset mutual debts or cross demands . . . .” (Internal quotation marks omitted.) *OCI Mortgage Corp.*v. *Marchese,*255 Conn. 448, 464-65, 774 A.2d 940 (2001). “The concept of setoff allows [parties] that owe each other money to apply their mutual debts against each other, thus avoiding the absurdity of making A pay B when B in fact owes A.” (Internal quotation marks omitted.) *Keefe*v. *Norwalk Cove Marina, Inc.,*57 Conn. App. 601, 612, 749 A.2d 1219, cert. denied, 254 Conn. 903, 755 A.2d 881 (2000). The policy of the law of setoff is to prevent unnecessary litigation where entire justice can be done to both of the parties before the court. See *Hope’s Architectural Products, Inc.*v. *Fox Steel Co.,*44 Conn. App. 759, 762, 692 A.2d 829, cert. denied, 241 Conn. 915, 696 A.2d 985 (1997). The $5000 retainer payment is not squarely the subject of a setoff because it is not a cross demand for payment of a debt owed to the defendant.

In light of the foregoing, we conclude that in this action to recover in quantum meruit for legal services *510rendered, the court properly calculated the plaintiffs award with respect to the $5000 credit. The $5000 credit is legally and logically correct and flows from the facts found by the referee, notwithstanding the defendant’s failure to plead the $5000 retainer payment as a special defense or setoff. Accordingly, we reject the plaintiffs claim.

The judgment is affirmed.

In this opinion the other judges concurred.

2

 In *Shapero*v. *Mercede,*66 Conn. App. 343, 784 A.2d 435 (2001), rev’d, 262 Conn. 1, 808 A.2d 666 (2002), we reversed the judgment of the trial court rendered in favor of the plaintiff in the amount of $22,500. The trial court rendered judgment in accordance with the report of an attorney trial referee (referee) to whom the matter had been referred. The report recommended judgment for the plaintiff in the amount of $22,500 in his action seeking, inter alia, quantum meruit damages for legal services provided to the defendant.

In reversing our decision, our Supreme Court held that we improperly concluded that because the plaintiff had not produced evidence showing either his rate of compensation or the prevailing rates in the community, there was insufficient evidence on which to base an award. *Shapero*v. *Mercede,*262 Conn. 1, 6, 808 A.2d 666 (2002). Specifically, our Supreme Court held that the referee’s general knowledge concerning the reasonable value of legal services, and her unchallenged factual findings with regard to the plaintiffs experience and reputation and the novelty and complexity of the legal issues addressed in the course of the plaintiffs work for the defendant provided sufficient support for her challenged finding as to an appropriate hourly rate. See id., 7-10.

3

 This appeal involves the legal services performed in connection with only one of the parcels of real property owned by the defendant, specifically, the defendant’s real property located on Progress Street in Stamford. See footnote 7.

4

 The defendant did not pursue those special defenses at the hearing before the referee.

5

 The court’s memorandum of decision stated the following:

“The court has been requested to articulate upon the following issue:

“1. What was the factual and legal basis for allowing the defendant to obtain a $5000 credit when he did not plead a setoff or special defense regarding the same?

“Articulation

“The attorney trial referee heard the evidence and awarded the plaintiff recovery on the basis of quantum meruit. The law provides that quantum meruit is predicated on and limited to the reasonable value of services rendered. The attorney trial referee found the reasonable value of the services rendered by the plaintiff was $27,500, or 100 hours at the rate of $275 per hour. The attorney trial referee took into account the fact that this sum represents the full amount due and owing the plaintiff for all work performed. Since the plaintiff had already been compensated in part in the amount of $5000, the attorney trial referee properly subtracted that sum from the award.

“The plaintiff has the burden of establishing value. A reduction of a retainer does not require special pleading such as setoff or special defense. The evidence was that the value was $27,500 and that $5000 had been paid. Therefore, the balance due was $22,500.”

6

 Although we stated that we disagreed with the plaintiffs claim regarding the $5000 credit; *Shapero*v. *Mercede,*supra, 66 Conn. App. 353; we went on to state that “[bjecause we have concluded that the referee acted outside her discretion in assigning a value to the plaintiffs services, we need not reach the plaintiffs claim on cross appeal.” Id.

7

 Although the defendant did plead a special defense alleging payment in the amount of $6559.03, that special defense did not relate to the same legal services that were the subject of the hearing before the referee. See footnote 4. Rather, the defendant’s special defense alleged payment for legal services performed in connection with his real property located on Canal Street and addressed the allegations contained in the first five counts of the plaintiffs complaint. Prior to the hearing before the referee, however, the plaintiff admitted receipt of the $6559.03 payment for services involving the Canal Street property, but denied receiving payment for services performed in connection with the defendant’s real property located on Progress Street in Stamford, as alleged in counts six through ten of the complaint. Consequently, the legal services at issue at the hearing involved services performed in connection with the Progress Street property. Accordingly, the first five counts of the plaintiffs complaint and the defendant’s special defense alleging payment were not the subject of the referee’s findings or the trial court’s judgment, and they are not at issue on appeal.

8

 At oral argument, the plaintiff argued further that the defendant could have, and should have, sought to amend his pleading to include a special defense or setoff claiming the $5000 credit so as to conform to the evidence adduced at the hearing. See Practice Book § 10-62; see also *Wilburn*v. *Mount Sinai Medical Center,*3 Conn. App. 284, 287, 487 A.2d 568 (1985) (“trial court may allow, in its discretion, an amendment to pleadings before, during, or after trial to conform to the proof’).

9

 In the sixth count, labeled “Quantum Meruit,” the plaintiff alleged, inter alia, that (1) “the [defendant retained the [pjlaintiff,” (2) “[tjhe legal fee agreement between the [pjlaintiff and the [djefendantwas reduced to writing and set forth the contingent nature of the legal fee arrangement,” (3) “[tjhe [djefendant terminated the legal fee agreement so as to avoid paying a contingent legal fee to the [pjlaintiff,” and (4) “the [pjlaintiff is entitled to the reasonable value of the legal services he performed which has benefited of the [djefendant to the [pjlaintiff’s financial detriment.”

The plaintiff appended the retainer agreement to his complaint as “exhibit A,” and his sixth count refers to and incorporates the retainer agreement by reference. See footnote 11.

10

 In *Cole*v. *Myers,*supra, 128 Conn. 223, an action brought by an attorney to recover a fee for legal services rendered, the attorney, like the plaintiff in the present case, had been employed on a contingency fee basis to obtain a reduction in tax assessments, but was discharged by the client before he had fully or substantially performed, and the client obtained a settlement through other attorneys. Id., 224-27. Our Supreme Court held that the discharged attorney was entitled to recover only on a quantum meruit basis, notwithstanding that the contracted for contingency occurred after the attorney’s discharge. See id., 228-30; see also 56 A.L.R.5th 85-92, § 8 [a] (1998). In so ruling, the court explained that “[a]n attorney at law is an officer of the court; a minister of justice. He is entitled to *fair compensation for his services,*but since, because of the highly confidential relationship, the client may discharge him even without just cause, he should receive *reasonable compensation for the work he has done*up to that point .... This rule *505is not unfair to the attorney. He will receive fair compensation for what he has done; *his position as an officer of the court does not entitle him to receive payment for services he has not rendered.”*(Emphasis added.) *Cole*v. *Myers,*supra, 230.

11

 The retainer agreement bears the parties’ signatures, lists a schedule of contingency fee payment amounts and provides, in relevant part: “This letter is to serve as an agreement between [the plaintiff] and [the defendant] concerning [1he plaintiffs] services as an attorney in connection with property owned by [the defendant] and located on Progress Drive in Stamford. . . .

“If this letter is satisfactory and reflects your [the defendant’s] understanding of [the] agreement, would you [the defendant] please sign the copy of *506this letter . . . and return it to [the plaintiff] with a retainer of $5000 which will be credited against any fees due under the terms of this letter.....”

12

 The plaintiff objected on the ground that the defendant had not pleaded a special defense or setoff regarding the retainer payment.

13

 See footnote 5.

14

 We note that the Rules of Professional Conduct expressly prohibit an attorney from keeping unearned retainer fees. See Rules of Professional Conduct 1.16 (d) (“[u]pon termination of representation, a lawyer shall . . . [refund] any advance payment of fee that has not been earned”) and rule 1.5, commentary (“[a] lawyer may require advance payment of a fee, but is obliged to return any unearned portion”); see *State*v. *Fernandez,*254 Conn. 637, 650 n.19, 758 A.2d 842 (2000) (“[r]ule 1.16 (d) of the . . . Rules of Professional Conduct requires attorneys, upon withdrawal from representation, to return to a client any unearned portion of a retainer”), cert. denied, 532 U.S. 913, 121 S. Ct. 1247, 149 L. Ed. 2d 153 (2001).

15

 That is especially trae in cases such as the present one, where the party seeking recovery in quantum meruit is an attorney, an officer of the court, the prior payment is compensation in part for the legal services on which the sought for recovery is based, and the attorney does not contest the factual finding that the prior payment was made.

16

 Practice Book § 10-50 governs the pleading of special defenses and provides in relevant part: “No facts may be proved under either a general or special denial except such as show that the plaintiffs statements of fact are untrue. Facts which are consistent with such statements but show, notwithstanding, that the plaintiff has no cause of action, must be specially alleged. Thus . . . payment (even though nonpayment is alleged by the plaintiff) . . . must be specially pleaded . . . .” The burden of pleading and proving the special defense of payment rests on the defendant. See *New England Savings Bank*v. *Bedford Realty Corp.,*246 Conn. 594, 606 n.10, 717 A.2d 713 (1998); *Selvaggi*v. *Miron,*60 Conn. App. 600, 601, 760 A.2d 539 (2000).

17

 Practice Book § 10-54 governs the pleading of setoffs and provides in relevant part: “In any case in which the defendant has either in law or in equity or in both a . . . right of setoff, against the plaintiffs demand, the defendant may have the benefit of any such setoff ... by pleading the same as such in the answer, and demanding judgment accordingly; and the same shall be pleaded and replied to according to the rules governing complaints and answers.”

18

 We note that because “[t]he design of these rules being to facilitate business and advance justice, they will be interpreted liberally in any case where it shall be manifest that a strict adherence to them will work surprise or injustice.” Practice Book § 1-8. Further, the “[rjules of practice must be construed reasonably and with consideration of this purpose. . . . Rules are a means to justice, and not an end in themselves; their purpose is to provide for a just determination of every proceeding.” (Internal quotation marks omitted.) *Webster Bank*v. *Zak,*71 Conn. App. 550, 558 n.5, 802 A.2d 916, cert. denied, 261 Conn. 938, 808 A.2d 1135 (2002).

19

 See footnotes 9 and 11.