Plaintiffs, who are applicants for or recipients of Aid to Families with Dependent Children, Food Stamps, or Medicaid, brought this class action in the United States District Court for the District of Oregon against Kevin Concannon as Director, Oregon Department of Human Resources’ and Freddye Webb-Petett1 as Administrator of the Department’s Adult and Family Services Division. Plaintiffs sought declaratory relief and an injunction compelling the defendants to hold hearings and issue administrative decisions under the Aid to Families with Dependent Children (AFDC), Food Stamp, and Medicaid programs within federally prescribed time limits. The plaintiffs alleged that the defendants’ failure to issue timely decisions violated federal statutes, implementing regulations and the due process clause of the Fourteenth Amendment.2 Both sides moved for summary judgment. Holding that the defendants had substantially complied with the regulations, the district court granted the defendants’ motion for summary judgment. We reverse that decision and remand for further proceedings consistent with this opinion.
Discussion
We review de novo the district court’s judgment dismissing this ease on the defendants’ motion for summary judgment. See, e.g., California Architectural Bldg. Prods. v. Franciscan Ceramics, 818 F.2d 1466, 1468 (9th Cir.1987), cert. denied, 484 U.S. 1006, 108 S.Ct. 698, 98 L.Ed.2d 650 (1988).
Congress created the AFDC, Food Stamp, and Medicaid programs to deliver subsistence income, nutrition, and medical care to eligible recipients. 42 U.S.C. § 601 et seq.; 42 U.S.C. § 1396a et seq.; 7 U.S.C. §2011 et seq. The federal government partially funds each of these programs. A state’s participation is optional, but participating states must comply with federal requirements. See King v. Smith, 392 U.S. 309, 316, 88 S.Ct. 2128, 2132-33, 20 L.Ed.2d 1118 (1968). Oregon has chosen to participate in all three programs. The Adult and *1387Family Services Division (AFSD) administers the programs in Oregon.
In each assistance program an applicant or recipient aggrieved by a state agency’s action has the right to a “fair hearing.” 42 U.S.C. § 602(a)(4) (AFDC); 42 U.S.C. § 1396a(a)(3) (Medicaid); 7 U.S.C. § 2020(e)(10) (Food Stamps). Federal regulations, which have the force and effect of law, require each state agency to take final action within ninety days from the date a hearing is requested in the AFDC and Medicaid programs, and within sixty days in the Food Stamp program. 45 C.F.R. § 205.10(a)(16)(l) (“Prompt, definitive, and final administrative action shall be taken within 90 days from the date of the request for a[n] [AFDC] hearing”); 42 C.F.R. § 431.244(f) (“The agency must take final administrative action within 90 days from the date of the request for a [Medicaid] hearing”); 7 C.F.R. § 273.15(c)(1) (“Within 60 days of receipt of a request for a fair [Food Stamps] hearing, the State agency shall assure that the hearing is conducted, a decision is reached, and the household and local agency are notified of the decision”).
Although these regulations direct that the agencies administering the three programs “shall” or “must” provide hearings within a prescribed time, defendants argue, and the district court held, that all that is required of the state is that the agency be in “substantial compliance” with the federal regulations. This argument is not without support. The AFDC statute provides that federal funding of a state’s program may be terminated if the state has failed “substantially” to comply with the federal hearing standards. 42 U.S.C. § 604(a)(2). Food Stamp funding may be terminated when a state fails to comply with such federal standards without “good cause.” 7 U.S.C. § 2020(g). These provisions have led one circuit to conclude that Congress could not have intended that states be held to any higher standard than that of “substantial compliance” when applicants or recipients seek an injunction to assure timely decisions. Shands v. Tull, 602 F.2d 1156, 1160-61 (3rd Cir.1979).
We are not convinced, however, that the standard for termination of federal funding, a virtual death sentence for a state’s program, is the appropriate one to define the rights of applicants and recipients of program benefits. The funding standard is not intended to be the measure of what the regulations require;3 it is intended to measure how great a failure to meet those requirements should cause funds to be cut off. The language of the federal regulations is unequivocal, and states that a decision “shall” or “must” be made within the specified number of days.4 The regulations’ commands effectuate the purposes of the federal categorical programs, to render reasonably prompt assistance to persons in dire need. From the standpoint of the applicants or recipients who are denied hearings and decisions within the time mandated by federal regulations, it is no comfort to be told that there is no federal remedy5 because the state is in “substantial compliance” with the federal requirements.
We conclude that the district court erred, then, in determining that plaintiffs were entitled to no more than substantial compliance. The defendants argue, in effect, that it is not practical for them to achieve total compliance as a program, and it would be improper to compel them to do *1388so by injunction. An injunction requiring adherence to the regulations, however, imposes no inappropriate obligation on the state. As the Seventh Circuit observed when it upheld an injunction requiring Indiana to comply with the requirements of the Food Stamp Act:
Because the defendants are required to comply with the Food Stamp Act under the terms of the Act, we do not see how enforcing compliance imposes any burden on them. The Act itself imposes the burden; this injunction merely seeks to prevent the defendants from shirking their responsibilities under it.
Haskins v. Stanton, 794 F.2d 1273, 1277 (7th Cir.1986). The fact that absolutely perfect compliance is unattainable does not of itself preclude an injunction requiring the state to comply with the regulations.
As with any program of this size, a few inadvertent errors are inevitable, and we are confident that the district court will not exercise its equitable powers to hold the state in contempt for every minor, inadvertent infraction of the Act if the court is satisfied that the officials are complying with the Act as strictly as is humanly possible.
Id. Impossibility of perfect compliance, then, may be a defense to contempt, but it does not preclude an injunction requiring compliance with the regulations when a pattern of non-compliance has been shown to have existed.
Haskins differs from our case in that in Haskins the district court had issued the requested injunction; here the district court refused it. We do not mean to imply that the district court has no discretion in deciding whether or not the equitable remedy of injunction is called for. Certainly an injunction is not required whenever an agency, that is otherwise in full compliance fails in one or a very few sporadic instances to hold a hearing and issue a decision on time. We hold, however, that the regulations require compliance, not “substantial compliance.” That a state, having previously been guilty of repeated instances of noncompliance, is in or has brought itself into “substantial compliance” is not a sufficient reason for denying declaratory or in-junctive relief. There is, however, doubtless a point at which any failure of total compliance is truly de minimis, where the state has come to comply “as strictly as is humanly possible,” and it is within the discretion of the district court to deny injunc-tive relief.
Here the district court made no determination whether Oregon had performed to such a degree of near-total compliance, because it concluded, incorrectly as we hold, that substantial compliance was enough. Even in applying that standard, however, the district court made an error that we believe we should point out because it may affect the court’s determination whether to issue an injunction on remand under the more demanding standard that we adopt today.
The district court excluded from its calculations of the degree of Oregon’s compliance all cases of overpayment. In so doing, the court relied on Oregon Administrative Rules.6 The Code of Federal Regulations, however, is the appropriate source to look to in determining whether overpayment cases are to be excluded. Nothing in the language of the federal regulations supports the proposition that overpayment cases constitute an exception to the general rules requiring a decision to be issued in sixty days in the Food Stamp program or ninety days in the AFDC and Medicaid programs.
In the AFDC program, the state agency must grant a hearing to “any applicant who requests a hearing because his or her claim for financial assistance ... is denied ... and to any recipient who is aggrieved by an agency action resulting in suspension, reduction, discontinuance, or termination of assistance ...” 45 C.F.R. § 205.-10(a)(5). The Medicaid and Food Stamp *1389programs contain similar provisions. 42 C.F.R. § 431.220(a)(2) (Medicaid); 7 C.F.R. § 273.15(a) (Food Stamps). Overpayment decisions often result in reductions in benefits to recoup the overpayments, thus triggering the application of the fair hearing requirements.7 Even though the recoup-ments may not be deducted until after a hearing is held, delay is detrimental to the recipient who remains uncertain whether he or she is accumulating a recoupment debt. Overpayment hearings thus fall within both the terms and the policy of the regulations. The district court accordingly should have incorporated the overpayment cases into its calculations.
The plaintiffs contend that the district court also erred by including “aborted hearings” in the total number of hearings when determining the degree of AFSD’s compliance with the regulations. We conclude, however, that the district court was correct in taking aborted hearings into account. The regulations simply require that the agency take final action within a specified number of days after a request for hearing. The agency complies with those regulations if it is able to take final action after a withdrawal, abandonment, or settlement of the applicant’s or recipient’s grievance. In some cases the agency will have put substantial effort into a case before the hearing is aborted; in many it will have acted as expeditiously as the regulations require. The agency should not be deprived of credit for its efforts simply because the grievance has been abandoned or settled. In addition, we are reluctant to endorse a method of accounting for compliance that would discourage an agency from taking actions leading to settlement of grievances in preference to insistence upon a hearing. We conclude, therefore, that the district court did not err in taking aborted hearings into account.
Conclusion
Because the district court erred in granting summary judgment for the defendants on the ground that the state had brought itself into “substantial compliance” with federal regulations, we reverse and remand for further proceedings. Plaintiffs are entitled under the regulations to compliance, not substantial compliance. In deciding, after such further proceedings on remand as the district court determines to be appropriate, whether to grant injunc-tive relief, the district court should consider whether, in light of circumstances then prevailing, the state has eliminated all but the truly inevitable instances of noncompliance.
REVERSED AND REMANDED.
. Stephen Minnich has since been substituted for Ms. Webb-Petett, having succeeded her in office.
. Plaintiffs do not assert the due process claim on this appeal.
. Our reliance on the regulations is what separates us from the dissent. The dissent argues that Congress, while not being explicit, required no more than substantial compliance. But the federal agencies responsible for the administration of these programs have issued quite explicit regulations requiring compliance with specified deadlines. The dissent does not show how these regulations conflict with the governing statutes.
. The defendants here have not argued that the federal statutes and regulations fail to create a private right of action. See Haskins v. Stanton, 794 F.2d 1273, 1274-75 (7th Cir.1986) (finding such an implied right of action for violation of Food Stamp Act).
.The state contends that individuals who are denied timely hearings have a remedy akin to mandamus under the state Administrative Procedure Act, Or.Rev.Stat. § 183.490. Plaintiffs dispute the effectiveness of this remedy. The district court did not address the question, and we express no opinion on it.
. The court stated: "The applicable regulations do not mention overpayments. The OAR requires hearing decisions in "public assistance” cases and "public assistance" cases are defined under OAR 461-09-310(a) and (b) as requests for benefits. A claim of overpayment is separately listed under OAR 461-09-310(a)(c).”
. The AFDC regulations, for example, require that "[t]he State must take all reasonable steps necessary to promptly correct any overpayment” and "[a]ny recovery of an overpayment ... must be recovered through repayment (in part or in full) by the individual responsible for the overpayment or recovering the overpayment by reducing the amount of any aid payable to the assistance unit of which he or she is a member, or both." 45 C.F.R. §§ 233.-20(a)(13)(A) and 233.20(a)(13)(A)(1). The regulation then provides that where recovery is made from the grant, the grant is to be reduced by up to 10% of the grant amount. 45 C.F.R. 233.20(a)(13)(A)(2). See also 7 C.F.R. § 273.-18(d)(3)(i) (recoupment of food stamp over-payments).