
97 P.3d 152 (2003)
Chad MARTINEZ, Plaintiff-Appellant,
v.
COLORADO DEPARTMENT OF HUMAN SERVICES and Otero County Department of Social Services, Defendants-Appellees.
No. 02CA1880.
Colorado Court of Appeals, Div. V.
October 9, 2003.
Rehearing Denied December 18, 2003.
Certiorari Denied September 13, 2004.
*154 The Carey Law Firm, L. Dan Rector, Leif Garrison, Robert B. Carey, Colorado Springs, Colorado, for Plaintiff-Appellant.
Ken Salazar, Attorney General, Laurie A. Schoder, Assistant Attorney General, Denver, Colorado, for Defendants-Appellees.
Opinion by Judge VOGT.
The issue in this case is whether Colorado may require indigent disabled persons who receive state interim assistance benefits to *155 reimburse the state out of their federal assistance benefits without paying a share of the legal fees incurred by the disabled persons in obtaining those federal benefits. Contending that it may not, plaintiff, Chad Martinez, filed this proposed class action against defendants, Colorado Department of Human Services (DHS) and Otero County Department of Social Services. Plaintiff appeals from the trial court's judgment dismissing his complaint for failure to state a claim upon which relief can be granted. We affirm in part, reverse in part, and remand for further proceedings.
After he was injured in a motor vehicle accident, plaintiff applied to the Social Security Administration (SSA) for federal Supplemental Security Income (SSI) benefits. His application was initially denied. Plaintiff retained an attorney to represent him in an appeal of that denial.
While his SSI appeal was pending, plaintiff applied for interim assistance under the state's Aid to the Needy Disabled (AND) program. In connection with that application, plaintiff executed an "Authorization for Reimbursement of Interim Assistance," in which he authorized SSA to send his first posteligibility payment of SSI benefits to the Otero County Department of Social Services "in consideration for the public assistance benefits paid to me" by the county under the state AND program. He authorized the county to deduct from that SSI payment the amount of interim assistance he had received from the state. Plaintiff thereafter began receiving interim assistance benefits from the state.
Plaintiff's SSI appeal was successful. He was awarded SSI benefits retroactive to the date he became eligible for them, as well as prospective benefits of $482 per month. In accordance with plaintiff's authorization, SSA sent a check for $5,069 to Otero County. The county retained the full amount as reimbursement for the interim assistance benefits it had paid to plaintiff.
Plaintiff commenced an administrative appeal in which he contended that defendants had been unjustly enriched by retaining the entire amount of his retroactive SSI benefits without paying a share of the legal fees he incurred and paid in successfully appealing SSA's initial denial of benefits. An administrative law judge agreed and issued an initial decision directing defendants to reduce the recoupment from plaintiff's retroactive SSI payment by twenty-five percent, or $1,267. The DHS office of appeals reversed the initial decision and entered summary judgment for defendants.
Plaintiff then filed a petition for judicial review and class action complaint in district court, asserting claims for declaratory relief, restitution based on unjust enrichment, breach of contract, and breach of the implied covenant of good faith and fair dealing. He asked the court to declare that he and others who had received state interim assistance benefits had the right to receive their past due SSI benefits directly and to reduce the reimbursement amount by defendants' pro rata share of their attorney fees, without regard to any contrary language in the authorization they had been required to sign.
Defendants filed a motion to dismiss, in which they argued that, under Gillens v. Colorado Department of Social Services, 644 P.2d 97 (Colo.App.1982), the authorization signed by plaintiff was "not a contract and not subject to analysis as such." By agreement of the parties, resolution of the class certification issue was stayed pending the trial court's ruling on defendants' motion.
The trial court granted the motion to dismiss. It concluded that, under Gillens,"it is clear that the AND benefits are to be considered a loan from the state, repayable when and if the applicant received SSI, rather than a contract. Therefore, [plaintiff's] claims are dismissed for failure to state a claim upon which relief can be granted" (citation omitted).

I.
Plaintiff contends that he stated a claim for declaratory relief, that Gillens is not dispositive of his right to such relief, and that the trial court therefore erred in dismissing his claim. We agree in part.
We review the grant of a C.R.C.P. 12(b)(5) motion to dismiss using the same *156 standards as the trial court. Thus, we uphold the trial court's grant of such a motion only if it appears beyond doubt that the plaintiff can prove no set of facts in support of his claim that would entitle him to relief. Rosenthal v. Dean Witter Reynolds, Inc., 908 P.2d 1095 (Colo.1995); Pomerantz v. Microsoft Corp., 50 P.3d 929 (Colo.App.2002).

A.
As an initial matter, we agree with plaintiff that he stated a claim for declaratory relief that should not have been dismissed for failure to state a claim.
C.R.C.P. 57(b) provides that any person interested under writings constituting a contract, or whose rights are affected by a statute or contract, may obtain a declaration of rights, status, or other legal relations thereunder. The right to a declaratory judgment also extends to a party who claims to be adversely affected by a regulation. See Bowen/Edwards Associates, Inc. v. Board of County Commissioners, 812 P.2d 656 (Colo.App.1990), aff'd in part and rev'd in part on other grounds, 830 P.2d 1045 (Colo.1992).
Here, plaintiff contended that his rights were adversely affected by a regulatory scheme that allowed defendants to retain money to which they were not lawfully entitled, and that he was an interested party under a written agreement between SSA and DHS that permitted SSA to send his federal benefits check to the county upon proper authorization. Thus, even if the authorization itself were not deemed a contract, plaintiff stated a claim for declaratory relief and was entitled to have a determination on the merits rather than a dismissal. See Karsh v. City & County of Denver, 176 Colo. 406, 490 P.2d 936 (1971)(in declaratory judgment action in which court rules against position of plaintiff, it should enter a declaratory judgment and not sustain a motion to dismiss).
However, we need not remand the claim to the trial court if the undisputed facts establish that plaintiff was not entitled to the requested declaratory relief as a matter of law. In that event, the issue may be resolved on appeal, and any error in the trial court's ruling would be harmless. See Karsh v. City & County of Denver, supra; Keybank v. Mascarenas, 17 P.3d 209 (Colo.App.2000).

B.
Plaintiff challenges the validity of the DHS regulation requiring him to sign the authorization that allowed SSA to send the full amount of his first SSI check to Otero County. Before addressing the merits of his contentions, we review the statutory and regulatory scheme governing the interim assistance payments at issue here.
Under the Colorado Public Assistance Act, § 26-2-101, et seq., C.R.S.2002, DHS supervises the administration of public assistance programs in Colorado, and county departments of social services assist in their administration. Among other programs, DHS administers the AND and Aid to the Blind (AB) programs, which provide interim assistance, paid for with state funds, for qualifying persons who are not receiving federal benefits. See § 26-2-111, C.R.S.2002. Both the AND and AB programs include among their criteria for eligibility a requirement that the recipient have applied for federal SSI benefits. See § 26-2-111(4)(b.5), (5)(a)(II), C.R.S.2002.
Under federal law, SSI benefits may be sent directly to states to reimburse them for interim assistance they have provided, if (1) the state has entered into a formal reimbursement agreement with SSA, and (2) the benefits recipient provides written authorization for such procedure. See 42 U.S.C. § 1383(g)(1).
Pursuant to § 26-2-206, C.R.S.2002, DHS is authorized to enter into the agreement with SSA contemplated under 42 U.S.C. § 1383(g)(1), "in accordance with [DHS] rules and regulations." DHS has in fact entered into such an agreement. Thus, when a Colorado applicant for SSI benefits has authorized it, the first SSI payment may go directly to the department of social services in the applicant's county to reimburse the state for its interim assistance payments.
In Gillens, a division of this court reviewed the statutory and regulatory scheme outlined above and rejected a contention that the authorization signed by the plaintiffs in that *157 case was a contract that had been breached when the state failed to pay their AND benefits promptly. The division reasoned that, because the AND benefits were a loan from the state, repayable when and if the applicants received SSI benefits, the authorization form "simply provided a convenient and painless method of repaying the loan on receipt of SSI funds." In reaching that conclusion, the division emphasized that the applicants voluntarily signed the authorization forms and thus were "in no position to complain." Gillens v. Colorado Department of Social Services, supra, 644 P.2d at 99.
The DHS regulations regarding interim assistance payments have changed since Gillens. At the time Gillens was decided, applicants could refuse to sign the authorization forms. In that event, assistance would still be provided, but the applicants were informed that a recovery action would be pursued if there was a duplication of assistance payments. Gillens v. Colorado Department of Social Services, supra.
Since 1996, however, DHS regulations have required applicants to sign authorization forms. DHS Reg. 3.450.43(A), 9 Code Colo. Regs. 2503-1, states:
As a condition of eligibility for State AND and/or State AB the applicant shall be required to sign the "Authorization for Reimbursement of Interim Assistance Payments Provided SSI Recipient." ... The client shall also be required to give signed authorization for recovery directly from him/her in the event that the first retroactive SSI check is sent to him/her rather than the county office of social services.
The authorization form referenced in Reg. 3.450.43(A) authorizes SSA to send the applicant's first SSI payment to the county in consideration for the public assistance benefits paid by the county. The form also authorizes the county to deduct from the SSI payment an amount equal to the sum paid to the applicant as interim assistance, represents that the county will pay the applicant any remaining balance after deducting that amount within ten working days from the date it receives the SSI payment, and provides that the applicant has a right to a hearing before an ALJ if he or she disagrees with the county's action. By signing the authorization, the applicant also represents that: "If I have not already filed an SSI application as of the date of this authorization, then this authorization shall serve as a signed, written statement of my intention to claim SSI benefits."

C.
Turning to the merits of the declaratory relief claim, we do not agree with plaintiff that DHS exceeded its authority or improperly added a new condition for eligibility for AND benefits by promulgating the regulation requiring applicants to sign the authorization described above.
An administrative agency must comply strictly with its enabling statutes, and it has no authority to set aside or circumvent legislative mandates. However, the General Assembly may permit an agency to promulgate rules and regulations to carry out the legislative purposes of the power granted to the agency. The General Assembly need not adopt a specific formula to guide agency rulemaking if the agency can find general guidance in the purposes and overall scheme of an act. Dodge v. Department of Social Services, 657 P.2d 969 (Colo.App.1982).
The purpose of the Colorado Public Assistance Act is to promote the public health and welfare by providing public assistance for the needy, "in cooperation with the federal government or independently." DHS and the counties are authorized to achieve that end by, among other means, "utilization of available resources of the federal government." Section 26-2-102, C.R.S.2002.
Section 26-2-206 authorizes DHS to enter into an agreement with SSA "in accordance with [its] rules and regulations." Further, in administering the AND and AB programs, DHS is authorized to promulgate rules that "require an applicant or recipient who may be eligible for benefits under another federal or state program ... to take reasonable steps to apply for, otherwise pursue, and accept such benefits." Sections 26-2-119(1), 26-2-120(1), C.R.S.2002.
*158 These statutes reflect the General Assembly's intent that persons receiving interim assistance from the state will pursue claims for federal benefits that can be used to offset sums expended by the state for interim assistance. The General Assembly also contemplated that DHS would promulgate regulations to further this purpose and to help ensure that the state would be reimbursed. The statutes thus afford sufficient guidance to permit DHS to promulgate the regulation at issue here. See Dodge v. Department of Social Services, supra.
Contrary to plaintiff's contention, we conclude that promulgation of Reg. 3.450.43(A) did not improperly impose a new condition for eligibility for AND benefits or fundamentally change legislative policy. As previously noted, in addition to satisfying other criteria for eligibility, recipients of AND and AB benefits must have applied for federal SSI benefits. See § 26-2-111(4)(b.5), (5)(a)(II). To the extent the authorization at issue here includes the applicant's representation that he or she intends to claim SSI benefits, it furthers the legislative intent reflected in those statutes. Further, in contrast to Rodgers v. Atencio, 43 Colo.App. 268, 608 P.2d 813 (1979), in which a regulation permitting the department of social services to withhold special need payments to AND recipients was held to be void because it fundamentally changed legislatively decreed policy, nothing in the regulation or the authorization amounts to a fundamental change in legislative policy.
We also note that, even under the regulatory scheme in effect when Gillens was announced, recipients of interim assistance payments had to reimburse the state upon receiving SSI benefits, although the state was required to undertake a separate action to recover such benefits if the applicants refused to sign the authorization. Thus, the regulation at issue here simply facilitates collection of an obligation that interim assistance recipients have to repay in any event upon receipt of SSI benefits.
We likewise reject plaintiff's contention that the authorization he signed is void and unenforceable because it was a product of duress or coercion. We are aware of no authority that holds that requiring compliance with a valid regulation amounts to duress or coercion. Tidwell v. Schweiker, 677 F.2d 560 (7th Cir.1982), on which plaintiff relies in support of this argument, involved a claimed violation of a federal statute not at issue here, and it does not stand for the proposition that authorizations provided in accordance with 42 U.S.C. § 1383(g)(1) are invalid because they are involuntary. See Splude v. Apfel, 165 F.3d 85 (1st Cir.1999)(noting that 42 U.S.C. § 1383(g)(1) specifically permits agreements authorizing use of SSI funds to repay interim state aid).
To the extent plaintiff sought a declaratory judgment that DHS could not validly require him to sign the authorization at issue here, we conclude that he was not entitled to such relief. Thus, dismissal of this aspect of his declaratory judgment claim was harmless error. See Keybank v. Mascarenas, supra.

D.
In light of our resolution of this issue, we further conclude that the trial court did not err in dismissing plaintiff's "breach of contract" claim.
Although this claim was denominated as one for breach of contract, plaintiff essentially sought a declaration that the authorization he signed was invalid and should be rescinded because no consideration was given in exchange for his signature. Plaintiff alleged that, although the authorization represents that he is authorizing SSA to send his SSI payment to the county "in consideration for" the interim assistance benefits he had received, this was no consideration because he was eligible to receive interim assistance payments even without signing the authorization.
However, we have concluded that DHS could validly require the signing of such authorization as a condition of receiving interim assistance benefits, and there is no allegation that defendants otherwise breached any contractual relationship they might have had with plaintiff. See Gillens v. Colorado Department of Social Services, supra, 644 P.2d at 99 (even if authorization form were viewed as contract rather than evidence of a loan *159 because of reference in it to "consideration," there was no evidence that state had breached it by failing to pay AND benefits promptly).
Accordingly, we conclude that plaintiff's breach of contract claim was properly dismissed for failure to state a claim.

II.
Our resolution of plaintiff's contentions regarding the validity of the DHS regulation and the authorization does not end our analysis. Plaintiff also sought a declaration that Reg. 3.450.43(A) was invalid because it inequitably allowed the state to retain the entire amount of his SSI benefits without paying any portion of the attorney fees he incurred in securing the SSI benefits. This contention is also the basis for plaintiff's second claim for relief, for unjust enrichment, and his fourth claim for relief, for breach of the implied covenant of good faith and fair dealing. Because we cannot resolve this issue as a matter of law on the record before us, we conclude that the trial court's order of dismissal must be reversed to the extent it dismissed the claims that were based on this contention, and the case must be remanded for further proceedings on the merits of these claims.

A.
We note at the outset that the statutory scheme outlined above is silent regarding any obligation on the part of the state to share in attorney fees incurred by recipients of state interim assistance in securing federal SSI benefits. In such circumstances, we may not infer that the General Assembly has abrogated otherwise applicable common law or equitable remedies. See Hawes v. Colorado Division of Insurance, 65 P.3d 1008 (Colo.2003)(unless legislature clearly and unmistakably abrogates a remedy available at common law, supreme court will not infer such abrogation; thus, where applicable statutes were silent, there was no legislative abrogation of equitable remedy that awarded common fund attorney fees for advocacy in administrative proceedings); St. Vincent's Hospital v. Alires, 778 P.2d 277 (Colo.App.1989)(where state workers' compensation statute addressing offsets for federal social security disability benefits did not specify how to treat portion of federal award that had already been paid to claimant's attorney pursuant to federal law, principles of unjust enrichment and policy considerations precluded employer and insurer from offsetting that portion).
Unjust enrichment is a judicially created remedy designed to avoid benefit to one to the unfair detriment of another. Unjust enrichment occurs when (1) at the plaintiff's expense, (2) the defendant received a benefit (3) under circumstances that would make it unjust for the defendant to retain the benefit without paying. See Salzman v. Bachrach, 996 P.2d 1263 (Colo.2000); American Family Mutual Insurance Co. v. Centura Health-St. Anthony Central Hospital, 46 P.3d 490 (Colo.App.2002).
Application of this doctrine arises out of the need to avoid unjust enrichment to a party even in the absence of an actual agreement to pay for the services rendered. Dudding v. Norton Frickey & Associates, 11 P.3d 441 (Colo.2000). Thus, if the elements of unjust enrichment are established, a plaintiff may be entitled to relief, even in the face of a contract with a clearly expressed contrary intent, if justice requires. See DCB Construction Co. v. Central City Development Co., 965 P.2d 115 (Colo.1998); see also Denver Ventures, Inc. v. Arlington Lane Corp., 754 P.2d 785 (Colo.App.1988).
Because claims for relief based on unjust enrichment do not lie in tort, they are not barred by the Colorado Governmental Immunity Act, § 24-10-101, et seq., C.R.S.2002. See CAMAS Colorado, Inc. v. Board of County Commissioners, 36 P.3d 135 (Colo.App.2001). Rather, equitable relief based on unjust enrichment may be sought against a governmental entity when necessary to prevent manifest injustice. See Cherry Creek Aviation, Inc. v. City of Steamboat Springs, 958 P.2d 515 (Colo.App.1998); Kohn v. City of Boulder, 919 P.2d 822 (Colo.App.1995); cf. Dove Valley Business Park Associates, Ltd. v. Board of County Commissioners, 945 P.2d 395 (Colo.1997)(unjust enrichment claim *160 brought against county was properly dismissed where county was not enriched by temporary use of plaintiffs' money).
Where a complaint adequately avers the necessary requirements for an unjust enrichment claim, the claim should not be dismissed pursuant to C.R.C.P. 12(b)(5). In such circumstances, when the issue presented cannot be resolved as a matter of law, the claim must be reinstated. See American Family Mutual Insurance Co. v. Centura Health-St. Anthony Central Hospital, supra; Scott System, Inc. v. Scott, 996 P.2d 775 (Colo.App.2000).

B.
Applying these principles here, we note initially that the authorization signed by plaintiff does not contemplate any deduction for plaintiff's attorney fees. However, if the elements of unjust enrichment are established, such a deduction may nevertheless be warranted if justice so requires. See Dudding v. Norton Frickey & Associates, supra; DCB Construction Co. v. Central City Development Co., supra.
Plaintiff's complaint adequately averred the elements of an unjust enrichment claim, and we cannot conclude at this juncture that plaintiff will be unable to prove any set of facts that would entitle him to relief on this claim. See Rosenthal v. Dean Witter Reynolds, Inc., supra. Specifically, it appears undisputed that plaintiff incurred an expense  namely, the attorney fees he paid for legal assistance in his appeal of the denial of SSI benefits. Further, although defendants argue to the contrary, plaintiff may be able to establish that defendants received a benefit, in that they were reimbursed for interim assistance payments they had made but would not have recouped if he had not successfully prosecuted his SSI appeal. We note in that regard that, if plaintiff's federal SSI claim had been denied, or if SSA had granted federal benefits in an amount less than the state's interim assistance, plaintiff would not have been required to pay back any outstanding balance from his own resources. See DHS Reg. 3.450.43(D)(1), 9 Code Colo. Regs. 2503-1.
As to the third unjust enrichment element, defendants point out that plaintiff's successful application for SSI benefits resulted in additional benefits to him. Thus, defendants argue, the statutory scheme that does not require the state to contribute to plaintiff's attorney fees is "neither unjust nor inequitable." However, we cannot so conclude on the limited record before us. Nor can we conclude on this record that the present scheme is unjust, as plaintiff urges. For example, in support of his argument, plaintiff suggests that the assistance of counsel is generally necessary to succeed in appealing a denial of SSI benefits, and he asserts that the amount he paid to his attorneys was a typical fee. Although these assertions, like those of defendants, may be relevant to the equities of the case, they must be addressed in the trial court in the first instance based on a fully developed factual record.

C.
We are not persuaded by defendants' contention that we may decide this issue as a matter of law by adopting the rationale of cases from other jurisdictions that have declined to find unjust enrichment where the state did not share in attorney fees incurred by applicants for SSI benefits. See Neal v. Stanislaus County, 141 Cal.App.3d 534, 190 Cal.Rptr. 324 (1983); Pomann, Callanan & Sofen, P.C. v. Wayne County Department of Social Services, 166 Mich.App. 342, 419 N.W.2d 787 (1988). In those cases, the claims were brought by attorneys, and the courts reasoned that the state, as a preferred creditor under 42 U.S.C. § 1383(g)(1) & (2), was not required to share its reimbursement with the attorneys, who were also creditors of the assistance benefits recipients. Here, by contrast, the unjust enrichment claim is not asserted by plaintiff's counsel, who have been fully paid, but by plaintiff himself. In these circumstances, equitable considerations may warrant a different conclusion.
Also, in contrast to the cases cited by defendants, courts in other jurisdictions have relied on the doctrine of unjust enrichment or other equitable principles to require state agencies to share in attorney fees in circumstances similar to those present here. See *161 Hedgebeth v. Medford, 74 N.J. 360, 378 A.2d 226 (1977)(state seeking reimbursement of amounts it had paid to Medicaid recipient who had obtained recovery from third-party tortfeasor was required under equitable principles to pay pro rata share of recipient's attorney fees); White v. Sutherland, 92 N.M. 187, 585 P.2d 331 (App.1978)(where settlement of claim was accomplished through efforts of patient's attorneys, equities required that state social services department not be allowed repayment of entire amount of medical assistance reimbursement it claimed); Shearer v. Moore, 277 Pa.Super. 70, 419 A.2d 665 (1980)(where attorney for welfare recipient obtained settlement from which commonwealth would benefit, equity required that commonwealth pay proportionate share of welfare recipient's attorney fees); Simmons v. Cohen, 122 Pa.Cmwlth. 70, 551 A.2d 1124 (1988)(under equitable principles of Shearer, state could not limit its responsibility for reimbursement of legal expenses incurred by welfare recipients in recovering federal SSI benefits); see also Anderson v. Wood, 204 W.Va. 558, 514 S.E.2d 408 (1999)(state department seeking indemnification for its payment of plaintiff's medical expenses was liable for pro rata share of her attorney fees where state statute was silent on the issue).
This case is also distinguishable from Trevino v. HHL Financial Services, Inc., 945 P.2d 1345 (Colo.1997), on which the final agency decision relied in concluding that plaintiff was not entitled to relief under the "common fund" doctrine.
The common fund doctrine is based on principles of equity that require those who have benefited from litigation to share in its costs. The supreme court held in Trevino that a hospital was not obligated, under that doctrine, to pay a share of the attorney fees incurred by its former patient in obtaining a personal injury settlement that was used in part to pay the amount he owed to the hospital. In so holding, the court focused on the fact that the patient was obligated to pay the hospital for its services, regardless of the outcome of the personal injury action. Here, by contrast, even if the interim assistance payments are deemed to be a "loan," see Gillens v. Colorado Department of Social Services, supra, it was a loan that did not have to be repaid unless plaintiff successfully obtained SSI benefits. Thus, because defendants' right to repayment of this loan was contingent on plaintiff's successful recovery of SSI benefits, the equities here may be different from those in Trevino.
In sum, we conclude that further proceedings are required to resolve plaintiff's unjust enrichment claim, as well as his claims for declaratory relief and breach of the covenant of good faith and fair dealing, to the extent the latter are premised on defendants' refusal to share in the attorney fees incurred in securing SSI benefits.
The judgment dismissing plaintiff's breach of contract claim and his claim seeking a declaration that DHS could not validly require him to sign the authorization is affirmed. In all other respects, the judgment of dismissal is reversed, and the case is remanded to the trial court for further proceedings consistent with the views expressed here.
Judge ROTHENBERG and Judge CARPARELLI, concur.
