
144 Ill. App.3d 1071 (1986)
495 N.E.2d 616
THE PEOPLE OF THE STATE OF ILLINOIS, Plaintiff-Appellee,
v.
MICHAEL SPUDIC, Defendant-Appellant.
No. 4-85-0793.
Illinois Appellate Court  Fourth District.
Opinion filed July 3, 1986.
*1072 Daniel D. Yuhas, of State Appellate Defender's Office, of Springfield, for appellant.
Edmond H. Rees, State's Attorney, of Carlinville (Kenneth R. Boyle, Robert J. Biderman, and Gwendolyn Klingler, all of State's Attorneys Appellate Service Commission, of counsel), for the People.
Judgment reversed.
JUSTICE McCULLOUGH delivered the opinion of the court:
In January of 1982, following a bench trial on a charge of felony theft, defendant was found not guilty by reason of insanity. He was subsequently committed to the Department of Mental Health and Developmental Disabilities (DMHDD) on August 19, 1982. The docket entry reflecting the order of commitment states, in part, that the "maximum period of commitment shall be 5 years less credit for good behavior and any other credits allowable pursuant to the statute and *1073 Department of Corrections' rules and regulations." On August 27, 1985, defendant filed a motion for discharge on the basis that he had been committed for over three years, more than the maximum term permitted by the commitment order. The trial court denied the motion for discharge on the basis that section 5-2-4(h) of the Unified Code of Corrections (Code) took precedence over section 5-2-4(b) of the Act. (Ill. Rev. Stat. 1983, ch. 38, pars. 1005-2-4(h), (b)).
 1 An evidentiary hearing was held on October 3, 1985. A number of witnesses including defendant, his mother, and psychiatric personnel responsible for treating defendant, testified. A review of the facts is not essential to a disposition in this matter as the issue before this court involves a question of law. We may briefly state, however, that defendant testified that he had overcome his mental-health problems and was now capable of becoming a useful member of society. In opposition to this testimony, defendant's mother stated that she believed her son's mental-health condition was "about the same as when he entered" the Department. Treating psychiatrists testified that defendant's schizophrenic condition still represented a danger to others and that because of his present condition treatment should be continued. We have reviewed the testimony and conclude as did the trial judge that the State sustained its burden of demonstrating by clear and convincing evidence that defendant was subject to involuntary admission and in need of mental-health services on an inpatient basis. Defendant does not contest or dispute this finding.
The parties further agree that by applying day-for-day credit, the maximum term to which defendant was subject to incarceration would have been 2 1/2 years since the maximum term for felony theft, a Class III felony, is 5 years. At issue, however, is the interplay between sections 5-2-4(b) and 5-2-4(h) of the Unified Code of Corrections (Ill. Rev. Stat. 1983, ch. 38, pars. 1005-2-4(b), (h)). The trial court held that despite the fact that defendant had served more than the maximum term under section 5-2-4(b), subsection (h) of that same statute precluded defendant's release when the court determined that defendant was still subject to involuntary commitment or required mental-health services on an inpatient basis. Upon denial of the motion for discharge, defendant appeals. The question is whether the trial court had the authority to refuse to discharge defendant once it was established that defendant had already been confined in excess of the maximum length of time permitted under the Unified Code of Corrections.
The commitment, treatment, and discharge of persons acquitted by reason of insanity are governed by section 5-2-4 of the Code, which provides, in pertinent part:

*1074 "If the Court finds the defendant subject to involuntary admission or in need of mental health services on an inpatient basis, the admission, detention, care, treatment or habilitation, review proceedings, and discharge of the defendant after such order shall be under the Mental Health and Developmental Disabilities Code, except that the initial order for admission of a defendant acquitted of a felony by reason of insanity shall be for an indefinite period of time. Such period of commitment shall not exceed the maximum length of time that the defendant would have been required to serve, less credit for good behavior, before becoming eligible for release had he been convicted of and received the maximum sentence for the most serious crime for which he has been acquitted by reason of insanity. The Court shall determine the maximum period of commitment by an appropriate order." (Ill. Rev. Stat. 1983, ch. 38, par. 1005-2-4(b).)
Subsection (b) further provides that "[d]uring this period of time" (emphasis added), the defendant shall not be permitted to be in the community in any manner, subject to a number of conditions not applicable here. Subsequent portions of section 5-2-4 require that a mental-health-facility director apply to the court for a change in defendant's status, including discharge, should defendant's mental condition improve. Defendant, in like manner, is permitted to apply for a change in status, including discharge, at any point during his hospitalization. Upon application, a hearing must be held and the trial court is required to make findings and adjustments in defendant's status should the evidence warrant modification of the terms of defendant's commitment to the mental-health facility.
Subsection (h) upon which the trial court relied in denying defendant's motion for discharge provides:
"If the court finds that the defendant is subject to involuntary admission or in need of mental health services on an inpatient basis, it shall order the facility director not to discharge or release the defendant in accordance with paragraph (b) of this Section." (Ill. Rev. Stat. 1983, ch. 38, par. 1005-2-4(h).)
Apparently, the court believed that irrespective of the length of time defendant had been committed it was required to deny the motion for discharge once it determined that defendant was still in need of mental-health treatment.
 2 In People v. Tanzy (1983), 99 Ill.2d 19, 457 N.E.2d 390, the supreme court held that a defendant, acquitted by reason of insanity, was entitled of compensatory as well as good-time credit provided by Department of Corrections' regulations. To hold that only imprisoned *1075 persons would be eligible for compensatory good-time credit, the supreme court reasoned, would penalize insane persons of this class and unreasonably favor those who had been convicted. In reaching this conclusion the supreme court stated:
"The maximum period for which the insane person can be committed is determined by reference to the sentencing scheme. The maximum thus determined will represent the outer limit of the defendant's possible commitment. The defendant cannot be held beyond that maximum.
* * *
The legislature has provided that, in the case of a defendant acquitted of a felony by reason of insanity, the commitment shall not exceed the maximum length of time the defendant would have been required to serve, less credit for good behavior." (99 Ill.2d 19, 21-24, 457 N.E.2d 390, 397-98.)
It has subsequently been held that good-time credits cannot be revoked on the basis of subsequent bad conduct and are not earned by an insanity acquittee during the course of his confinement. Rather, the maximum period of confinement is merely computed by referring to the existing sentence scheme and good-time credit provisions contained in the criminal code. In re Commitment of Guy (1984), 126 Ill. App.3d 267, 466 N.E.2d 1252; see also People v. Larson (1985), 132 Ill. App.3d 594, 478 N.E.2d 439.
 3 Based on the foregoing authority, we conclude that section (h) of the Code does not operate to permit a trial court to extend a period of commitment beyond the maximum term set by reference to subsection (b) of the statute. The State argues that when the entire statute is read in conjunction, it is plain that if the court finds the patient is in need of inpatient mental-health treatment, he cannot be released despite the provisions of subsection (b) which grant defendant credit for good behavior. We disagree.
The proceedings under paragraphs (e), (f), (g) and (h) are not independent from the remainder of section 5-2-4. A petition filed under paragraph (e) and considered under the standards established by paragraphs (f), (g) and (h) is clearly subject to the restraints imposed by paragraph (b). Thus the court's prerogative to exercise its discretion under paragraph (h) to continue to hold a defendant to commitment under the original order exists only so long as defendant has not served the maximum term calculated under paragraph (b). During that time, should defendant's mental condition change so that alternate placement becomes appropriate, medical personnel or the defendant may apply for a court-ordered change in the treatment plan. After hearing, *1076 the court may or may not alter defendant's treatment. This comports with the stated policy that, in a real sense, a commitment of such a defendant is indefinite because the person may be released at any time he or she is determined to be sane, even if this is prior to the maximum term of involuntary commitment set by the trial court. People v. Tanzy (1983), 99 Ill.2d 19, 457 N.E.2d 390; People v. Hampton (1983), 121 Ill. App.3d 273, 459 N.E.2d 985.
Once, however, the maximum term has been reached, the defendant may no longer be held under the terms of section 5-2-4. If the acquittee has not recovered from his mental illness by the time the maximum term of commitment has been reached, he is, of course, still subject to a "civil" commitment under the terms of the Mental Health and Developmental Disabilities Code (Ill. Rev. Stat. 1985, ch. 91 1/2, par. 1-100 et seq.). See People v. Hampton (1983), 121 Ill. App.3d 273, 459 N.E.2d 985; Raimondo v. Pavkovic (1982), 107 Ill. App.3d 226, 437 N.E.2d 712.
This conclusion is bolstered by reference to proceedings involving defendants found guilty but mentally ill. Under section 5-2-6 of the Unified Code of Corrections (Ill. Rev. Stat. 1985, ch. 38, par. 1005-2-6), individuals found guilty but mentally ill may be sentenced to any term of imprisonment which could have been imposed upon a defendant convicted of the same offense without a finding of mental illness. The Department of Corrections may thereafter transfer a defendant to DMHDD for treatment. It is without doubt that such a defendant is entitled to statutory and good-time credits during the period of his incarceration. Significantly, subsection (d)(2) of the Code (Ill. Rev. Stat. 1985, ch. 38, par. 1005-2-6(d)(2)) provides that upon expiration of the sentence of any person committed under this section, if the DMHDD determines that defendant needs further hospitalization, it must file an appropriate petition for involuntary commitment pursuant to the Mental Health and Developmental Disabilities Code. See also Ill. Rev. Stat. 1985, ch. 38, par. 1003-8-6(c).
 4 In view of the foregoing, we reverse the judgment of the circuit court denying defendant's petition for discharge. We conclude that petitioner is entitled to his immediate release under the Code. The alternative remedy of civil commitment is, of course, available if sought by appropriate means. In re Commitment of Guy (1984), 126 Ill. App.3d 267, 466 N.E.2d 1252.
Reversed.
WEBBER and MORTHLAND, JJ., concur.
