
762 N.E.2d 663 (2001)
326 Ill. App.3d 1058
261 Ill.Dec. 94
Stephen GUZZO, Plaintiff-Appellee,
v.
Donald SNYDER and James Page, Defendants-Appellants.
No. 3-01-0002.
Appellate Court of Illinois, Third District.
December 28, 2001.
Rehearing Denied February 14, 2002.
*665 James Ryan, Attorney General, Joel D. Bertocchi, Solicitor General, William L. Browers, Kendall R. Mills (argued), Assistant Attorneys General, Chicago, for James Page, Donald Snyder.
Lawrence J. Weiner (argued), Scariano, Ellch, Himes and Petrarca, Chtd., Chicago, for Steven Guzzo.
Jean Maclean Snyder, MacArthur Justice Center, Chicago, for Amicus Curiae, MacArthur Justice Center.
Justice BRESLIN delivered the opinion of the court:
Petitioner Stephen Guzzo filed this action against defendants Donald Snyder, Director of the Illinois Department of Corrections (IDOC), and James Page [1] warden of Stateville Correctional Center. In his complaint, Guzzo alleged that the Director and warden failed to award him meritorious good-time credit and supplemental meritorious good-time credit (collectively, good-time credit) because of a domestic battery arrest in his criminal history. Guzzo petitioned for habeas corpus or mandamus and alleged that his civil rights were violated under section 1983 of the Civil Rights Act (42 U.S.C. § 1983 (1994)) and the constitutions of the United States and Illinois. The trial court dismissed Guzzo's civil rights and mandamus claims but granted his habeas corpus claim because it found the Director's unwritten policy of denying good-time credit to inmates arrested for domestic battery was arbitrary and capricious and an abuse of discretion. Based on the following discussion, we affirm and hold that the Director of the Department of Corrections abuses the discretion given him under section 3-6-3 of the Unified Code of Corrections (730 ILCS 5/3-6-3 (West 2000)) when he establishes an unwritten policy unrelated to prison discipline denying good-time credit to inmates who have been charged with or convicted of domestic battery.

FACTS
In 1997, 19-year-old Stephen Guzzo was arrested, charged, and pled guilty to two counts of mob action. While he was awaiting sentencing, Guzzo was arrested again and charged with domestic battery of his girlfriend. Because the prosecutor decided to nol-pros that charge, the case was dismissed. Guzzo was sentenced to 2½ years' probation on the mob action charges. While on probation, Guzzo was observed in the presence of several gang members in violation of his probation. As a result, Guzzo's probation was revoked, and he was sentenced to three years' incarceration with credit for time served. If Guzzo was awarded day-for-day credit and the maximum 180 days of good-time credit, his release date would have been August 20, 2000.
Guzzo filed a petition for mandamus relief, alleging that the Director was improperly *666 withholding from, him good-time credit and eligibility for work release and home monitoring. When the trial court dismissed Guzzo's mandamus petition without prejudice, he filed an amended complaint. In count I Guzzo sought habeas corpus relief. In count II he alleged violations of his civil rights, and in count III he petitioned for mandamus. The Director filed a motion to dismiss, claiming that Guzzo did not allege facts sufficient for either a habeas corpus or a mandamus claim and that an award of good-time credit did not amount to a constitutionally-protected liberty interest. The motion was granted as to counts II and III.
During discovery on the habeas corpus count, the Director acknowledged that, although he delegated the decision to award good time credit to IDOC's transfer coordinator, it was his regular practice and policy that inmates with domestic battery arrests in their criminal histories were to be denied good-time credit. At a subsequent hearing, the transfer coordinator testified that she learned of this practice and policy from her predecessor. To her knowledge, Rule 107 of the Administrative Code (20 Ill. Adm.Code § 107.210 (1996)) was the only rule or regulation regarding the award of good-time credit, and there were no written policies, memos, or letters concerning the practice of denying good time credit to inmates with a domestic battery arrest.
The transfer coordinator testified as to the procedure employed by the IDOC for granting good-time credit. A request for good-time credit begins at the institutional level with an inmate's counselor and is signed off by each institution's warden. It is then forwarded to the transfer coordinator. The transfer coordinator's staff would review the inmate's offense, release date, outstanding time revoked, criminal history, and institutional disciplinary record. A good-time credit request would be denied if something was irregular on the good-time credit form, such as a conviction requiring automatic exemption or a domestic battery charge. If no irregularities were found, the warden's recommendation for a good-time credit award was accepted. According to the transfer coordinator, she had never awarded good-time credit to an inmate with a domestic violence charge, nor had she ever heard that credit was given under those circumstances.
After the hearing, the court found that the Director abused his authority when he failed to award Guzzo good-time credit. The court determined that the Director's unwritten policy of denying good-time credit to any person arrested for domestic battery was arbitrary and capricious. In its order, the court directed the Director to review Guzzo's request for good-time credit within 13 days.
Although the warden recommended to the Director that Guzzo be awarded 90 days of good-time credit, the Director refused to grant Guzzo any credit. At a subsequent hearing, the court found that the Director's policy of denying good-time credit to inmates who had been arrested for but not convicted of domestic battery was unconstitutional and in violation of Illinois law. Because the court determined that Guzzo's continued custody was unconstitutional and because his time would have been up if he had been awarded the credit, the court ordered that Guzzo be immediately discharged. The court also ordered the Director to exercise his discretion and award Guzzo 54 days of good-time credit because he had 54 days left to serve on his sentence. The Director appealed.

ANALYSIS
The issue on appeal is whether the court erred when it ordered the immediate *667 release of Guzzo contrary to the Director's discretionary decision to deny good-time credit to inmates who had been arrested for domestic battery. We must also consider whether habeas corpus was the appropriate remedy for the trial court to have used. This court reviews questions of law, including the scope of an agency's power and authority, de novo. County of Knox ex rel. Masterson v. Highlands, L.L.C., 188 Ill.2d 546, 243 Ill.Dec. 224, 723 N.E.2d 256 (1999).
On appeal, the Director argues that because the award of good-time credit was discretionary, Guzzo was not entitled to receive the credit, and therefore Guzzo did not state any cognizable grounds upon which his release could be granted.
Section 3-6-3(a)(3) of the Unified Code of Corrections (Corrections Code) provides:
"[T]he Director may award up to 180 days additional good conduct credit for meritorious service in specific instances as the Director deems proper; except that no more than 90 days of good conduct credit for meritorious service shall be awarded to any prisoner who is serving a sentence for conviction of [various felonies]." 730 ILCS 5/3-6-3(a)(3) (West 2000).
Section 107.210 of the Illinois Administrative Code (Administrative Code) (20 Ill. Adm.Code § 107.210 (1996)), reflects the same provisions for awarding good-time credit. It also limits good-time credit for persons serving convictions for the same felonies included in section 3-6-3(a)(3) of the Corrections Code, none of which were at issue here. Although the Administrative Code grants the Director discretion in determining whether to award good-time credit, it sets out a number of factors that focus on an inmate's behavior in prison that the Director may consider in his exercise of discretion. 20 Ill. Adm.Code § 107.210 (1996). These factors include the prison reports on the inmate, his rule violations, educational progress, and job performance.
Section 3-2-2(1)(n) of the Corrections Code (730 ILCS 5/3-2-2(1)(n) (West 2000)) provides that the IDOC has the power to establish rules and regulations for administering a system of good-conduct credits. The rules and regulations are subject to review by the Prison Review Board. 730 ILCS 5/3-2-2(1)(n) (West 2000). Section 3-6-3(a)(1) of the Corrections Code (730 ILCS 5/3-6-3(a)(1) (West 2000)) states that the IDOC shall prescribe rules and regulations for the early release for good conduct of persons committed to the Department.
The Director is further restricted in his exercise of discretion by section 5-20 of the Illinois Administrative Procedure Act (Act) (5 ILCS 100/5-20 (West 2000)), which requires that an agency define as clearly and precisely as possible the standards by which it will exercise its discretionary power in order to fully inform those affected. Illinois courts require the legislature to articulate standards when it delegates authority in order to ensure that agency discretion is appropriately used. Stofer v. Motor Vehicle Casualty Co., 68 Ill.2d 361, 12 Ill.Dec. 168, 369 N.E.2d 875 (1977). Once such standards are established, the agency cannot impose by regulation or practice a requirement that is inconsistent with the statute conferring the authority. Hernandez v. Fahner, 135 Ill. App.3d 372, 90 Ill.Dec. 204, 481 N.E.2d 1004 (1985).
Although both the Corrections Code and the Administrative Code exclude particular classes of inmates from consideration for good-time credit, the exclusions in both codes are based on the inmate's commitment for specific crimes. Neither *668 code excludes inmates who have been arrested for domestic battery, nor do they exclude inmates arrested for but not convicted of the enumerated felonies. The award of good-time credit is conferred upon inmates as a means to acknowledge and encourage meritorious service by inmates and to promote prison discipline. See Lane v. Sklodowski, 97 Ill.2d 311, 73 Ill.Dec. 462, 454 N.E.2d 322 (1983) (determining that good-time credit award is a means of establishing control and discipline within prison). Although the Administrative Code allows the Director to consider factors aside from those listed, any factor that is considered should be connected with the purpose of the award of good-time credit. See Albazzaz v. Illinois Department of Professional Regulation, 314 Ill.App.3d 97, 247 Ill.Dec. 14, 731 N.E.2d 787 (2000) (finding that a doctor who attempted to have his medical license restored was entitled to be evaluated on the basis of the factors promulgated by the licensing board).
Because the refusal of Guzzo's good-time credit was based on an unwritten policy that excluded inmates with domestic battery arrests from eligibility, we affirm the trial court's decision and hold that the Director abused his discretion when he refused to award Guzzo good-time credit because the use of the unwritten policy was outside the scope of the Director's authority and in violation of the Act provisions on rulemaking and discretionary powers.
Having determined that the Director abused his discretion, we now consider the form of remedy.
Mandamus is an appropriate remedy to prevent a discretionary power from being used arbitrarily where the abuse results in a manifest injustice. People ex rel. Shell Oil Co. v. City of Chicago, 9 Ill.App.3d 242, 292 N.E.2d 84 (1972). As a general rule, mandamus may not be used to compel a public official to exercise discretion in a particular way; however, mandamus will properly lie to prevent a clear abuse of discretion or to control the exercise of discretion so that it is exercised consistent with the applicable law. People ex rel. Collins v. Young, 83 Ill.App.2d 312, 227 N.E.2d 524 (1967). When a discretionary power is exercised with manifest injustice, a court may command its due exercise. People ex rel. Collins, 83 Ill.App.2d at 318, 227 N.E.2d at 527. A showing of an abuse of discretion is not the only condition for mandamus relief; the defendant must have a clear duty to act and the plaintiff must show a clear right to the requested relief. Freeman v. Lane, 129 Ill.App.3d 1061, 85 Ill.Dec. 216, 473 N.E.2d 584 (1985).
In this case, the Director was authorized to award good-time credit based on the authority given to him pursuant to the Corrections Code. See 730 ILCS 5/3-6-3(a)(3) (West 2000) (authority to award good time credit); 730 ILCS 5/3-2-2(m) (West 2000) (authority to exercise all powers and duties vested in IDOC). The Director also had a clear duty under the Act to promulgate standards by which he would exercise his discretionary power. See 5 ILCS 100/5-20 (West 2000) (requiring that each agency rule implementing a discretionary power spell out the standards by which that power is to be exercised). The Director's policy of denying good-time credit based solely on an inmate's domestic battery arrest was both unwritten and unrelated to prison discipline. As such, the Director's policy is not an articulated standard and is not in accordance with IDOC rules, and the use of the policy is an abuse of the Director's discretion which implicates the mandamus exception. See Howell v. Snyder, 326 Ill. App.3d 450, 260 Ill.Dec. 236, 760 N.E.2d *669 1009 (2001) (concluding that the Director's unwritten policy is a refusal to exercise discretion for which mandamus would lie). Because the Director did not offer any other standard under which to deny good-time credit, we must assume that, but for the unwritten policy, Guzzo would have been entitled to the award of good-time credit.
Although the trial court discharged Guzzo under an order of habeas corpus, we do not agree that habeas corpus was the appropriate remedy. Under habeas corpus, the sole remedy is a prisoner's immediate discharge from custody. See People ex rel. Burbank v. Irving, 108 Ill.App.3d 697, 64 Ill.Dec. 303, 439 N.E.2d 554 (1982). Because it was necessary for the trial court to order the Director to exercise his discretion and grant Guzzo good-time credit before releasing him, he was not entitled to habeas corpus relief. See Helm v. Washington, 308 Ill.App.3d 255, 241 Ill.Dec. 871, 720 N.E.2d 326 (1999) (stating that an inmate's petition that sought a grant of sentencing credit was not appropriate for habeas corpus relief). We may, however, affirm on any basis in the record. See McGuire v. Ameritech Cellular Corp., 314 Ill.App.3d 83, 246 Ill. Dec. 815, 731 N.E.2d 343 (2000). Therefore, we hold that Guzzo was entitled to an immediate discharge from custody under mandamus.
In reaching our conclusion, we note that in Helm v. Washington, 308 Ill.App.3d 255, 241 Ill.Dec. 871, 720 N.E.2d 326 (1999), we affirmed the trial court's dismissal of the petitioner's request for mandamus relief and held that because the award of meritorious good-time credit was discretionary, mandamus was inappropriate. In Helm, however, the petitioner did not allege that the Director abused his discretion, which would implicate the mandamus exception, nor did he assert that he had a clear right to relief or that the Director had a clear duty to act. Helm, 308 Ill.App.3d at 257-58, 241 Ill.Dec. 871, 720 N.E.2d at 328.
For the foregoing reasons, the judgment of the circuit court of Will County is affirmed.
Affirmed.
HOMER, P.J., and LYTTON, J., concur.
NOTES
[1]  The warden was actually Kenneth Briley.
