
102 Wn.2d 466 (1984)
687 P.2d 1145
In the Matter of the Personal Restraint of ROBERT A. KNAPP, ET AL, Petitioners.
No. 50448-2.
The Supreme Court of Washington, En Banc.
September 6, 1984.
*467 Robert A. Stalker, Jr., and John Hughes of Evergreen Legal Services, for petitioners.
Kenneth O. Eikenberry, Attorney General, and Douglas D. Walsh, Assistant; Paul A. Klasen, Jr., Prosecuting Attorney for Grant County, and Jerald R. Hamley, Deputy, for respondents.
BRACHTENBACH, J.
Must time spent confined in a state mental hospital pursuant to a valid criminal conviction be credited against the offenders' subsequently imposed mandatory maximum and minimum discretionary sentences? That is the issue these consolidated personal restraint petitions present. We hold that the equal protection clause requires that credit be given for the time each petitioner spent committed as an inpatient at Eastern State Hospital (ESH). Because of our disposition of the issue we need not decide whether the double jeopardy clause or the state Law Against Discrimination, RCW 49.60.030, prohibits the denial of credit.
Petitioner Knapp pleaded guilty to possessing stolen property (a motor vehicle) in the second degree in 1978. The court deferred imposing the maximum sentence, 5 years, and placed the petitioner on 36 months' probation. As a condition of probation petitioner was ordered to enter and successfully complete a program at ESH. Knapp was found to be in need of mental health treatment because he was suffering from irresistible impulse to steal cars. The trial judge ordered Knapp immediately transported to ESH; Knapp was committed that same day.
Over the next 31 months Knapp progressed to work release status, but in November 1981 he left the hospital without authorization. He then stole a taxicab in downtown Spokane and after a high speed chase was apprehended. Knapp's probation was then revoked and the original 5-year sentence was reinstated.
The Board of Prison Terms and Paroles set his discretionary minimum term at 39 months, 18 months above the *468 guidelines. The Board's principal written reason for this term was that Knapp had participated in a court-ordered treatment program for the commitment offense, but immediately reoffended with a crime similar to the commitment offense. The Board set his maximum expiration date at September 20, 1986. The Board credited both sentences with 140 days Knapp spent in county jail, but denied any sentence credit for the time Knapp spent at ESH during his probation.
Petitioner Wallin was charged with second degree assault and second degree statutory rape. The prosecutor filed a petition of sexual psychopathy. RCW 71.06.020. On May 2, 1980, after a jury verdict of guilty on both counts, the trial court imposed the maximum sentence for each count, 10 years, which were to run consecutively. The court, however, suspended the sentences, and ordered the petitioner committed to ESH for a 90-day observation period to determine the allegation of sexual psychopathy. See RCW 71.06.040.
On July 31, 1980, the petitioner was returned to the court with a report from ESH that the petitioner was not a sexual psychopath. Despite this recommendation, the trial court independently concluded that the petitioner was a sexual psychopath and ordered his commitment to ESH for detention, care and treatment. See RCW 71.06.060.
One month later petitioner was returned to the county jail because he was found not amenable to treatment and not safe to be at large. The trial judge then put petitioner on probation and, as a condition, ordered him to enroll in the sexual offenders program at ESH. His probation was revoked when he failed to comply with this condition.
Wallin spent 2 months 24 days in ESH under the May 2, 1980, observation/evaluation commitment. The Board has interpreted "jail time" to include time spent under commitment in the state hospitals for observation and evaluation under RCW 71.06.040. Therefore, the observation/evaluation period, along with all jail time served by Wallin, totaling 490 days, was credited toward both his mandatory *469 maximum and discretionary minimum terms pursuant to State v. Phelan, 100 Wn.2d 508, 671 P.2d 1212 (1983) (Phelan II); In re Phelan, 97 Wn.2d 590, 647 P.2d 1026 (1982) (Phelan I); and Reanier v. Smith, 83 Wn.2d 342, 517 P.2d 949 (1974).
Wallin spent an additional 33 days in ESH for "treatment" under the July 31, 1980, commitment order. The Board credited this 33-day period toward the petitioner's maximum term pursuant to RCW 71.06.120[1] but refused to credit it against his discretionary minimum term.
Both petitioners filed separate personal restraint petitions in the Court of Appeals, arguing that the Board erred in denying them credit for their respective hospital time. The county respondent, in response to Knapp's petition, argued that he was not entitled to credit toward his mandatory maximum term. The Board, in response to both petitions, argued that neither petitioner was entitled to credit against their discretionary minimum sentences. The cases were consolidated and certified to this court pursuant to RCW 2.06.030(d).

I
While this court has never addressed whether "nonjail" custodial confinement in a state facility pursuant to a valid criminal conviction must be credited against an individual's prison term, we have previously dealt with the issue of sentence credit.
In Reanier v. Smith, 83 Wn.2d 342, 517 P.2d 949 (1974), we held that the denial of credit against the maximum and mandatory minimum terms for pretrial detention is unconstitutional. We stated:
Furthermore, our statutes, RCW 9.95.062 and RCW 9.95.063, provide for detention credit pending the appeal of a conviction as well as credit for time served prior to a *470 resentencing where a new trial has been granted.
We can see no practical, realistic or substantive difference between time spent in pretrial detention for want of bail and time spent in detention pending an appeal of a conviction or time spent under a subsequently vacated and reinstated sentence. It is all time spent in confinement ...
...
"We conclude that considerations of ... equal protection ... dictate that presentence jail time be credited against maximum and mandatory minimum terms where applicable. Accordingly, pretrial detention time should be administratively credited..."
(Footnotes omitted. Italics ours.) Reanier, at 351-53.
One petitioner in Reanier, convicted of second degree assault, was seeking credit for the 23 months he spent in both the county jail and Western State Hospital prior to judgment and sentence. Neither this court nor the parties treated this fact as a distinguishing point in terms of sentence credit. See Reanier, at 343. See also In re Quinlivan, 22 Wn. App. 240, 243 n. 1, 588 P.2d 1210 (1978) (Reanier requires credit for petitioner's pretrial incarceration in Eastern State Hospital).
Reanier was followed in State v. Hultman, 92 Wn.2d 736, 600 P.2d 1291 (1979) and In re Phelan, 97 Wn.2d 590, 647 P.2d 1026 (1982). These two decisions hold that jail time served as a condition of probation must also be credited against the subsequently imposed mandatory minimum and maximum prison terms.
However, both cases rejected the contention that time served under the restrictions of probation but "not in actual detention", Phelan I, at 592, must also be similarly credited.
To allow credit for probationary time represents a change in policy of criminal sentencing from that of reinstating the original sentence upon revocation of an order of suspension.... [A]ny change in this policy should be made by the legislature.
(Footnotes and citations omitted.) Hultman, at 742-43 (probation conditions: fine, good behavior, payment of child *471 support); accord, In re Phelan, at 597-98 (probation conditions: abstain from alcohol, seek alcohol rehabilitation and observe all laws of state). Thus Reanier, Hultman, and Phelan I recognize a clear constitutional distinction between credit for "jail time" and credit for "nondetention" time. These decisions stand for the general proposition that credit for nonjail probation time is a matter for the Legislature and a denial of credit for that time is not unconstitutional.
Reanier was most recently followed in State v. Phelan, 100 Wn.2d 508, 671 P.2d 1212 (1983) (Phelan II). Phelan II held that under the equal protection clause and the double jeopardy clause, discretionary minimum terms must also be credited for all "jail time" served. Phelan II, at 513-17.
Phelan II, noting the recent Supreme Court decision in Plyler v. Doe, 457 U.S. 202, 72 L.Ed.2d 786, 102 S.Ct. 2382 (1982), found that a denial of presentence jail time involved both a deprivation of liberty in addition to that which would otherwise exist, and a classification based solely on wealth. Therefore, the court applied an intermediate level of scrutiny; requiring the denial of credit to be fairly viewed as furthering a substantial interest of the State. This court concluded that the denial of credit could not be fairly viewed as furthering the State's interest in rehabilitation and, therefore, did not meet the enhanced review that was applicable. Phelan II, at 512-14.
With this precedent in mind we reiterate that credit for nonjail probation time is properly a matter for the Legislature. However, while not directly addressing probationary time credit, the Legislature has addressed the issue of credit for hospital time, thereby providing guidance.
In general, if a person convicted of a crime and incarcerated in a correctional facility or institution is determined to be in need of mental health assistance, he can be "transferred or moved for observation, diagnosis or treatment to any state institution or facility for the care of the mentally ill ...". RCW 72.68.031. Once transferred, both his mandatory maximum and discretionary minimum terms will *472 continue to run during the period he is detained or confined at that mental health facility. RCW 72.68.031.[2] Additionally, the Legislature has determined that after a person is committed to a state hospital pursuant to a determination of sexual psychopathy, all time in the state hospital shall count as part of his sentence. RCW 71.06.120.[3]
In Reanier, Hultman, Phelan I and Phelan II, the lack of direct legislative activity did not prevent, and in fact necessitated, our action. Similarly, the lack of direct legislative action, coupled with the legislative action embodied in RCW 71.06.120 and RCW 72.68.031, leads to our result in this case.

II
The respondents assert that the analysis of Reanier and *473 its progeny is applicable only to "jail time" and does not apply to "nonjail time". The respondents argue that the petitioners are not similarly situated to persons confined in jail because "jail time" serves all four purposes of punishment, i.e., rehabilitation, retribution, incapacitation and deterrence, while the petitioners' "treatment time" serves the principal purpose of rehabilitation.
[1, 2] Assuming arguendo that the petitioners are not similarly situated to individuals who serve probationary jail time, they are similarly situated to each other.
Rather, we need only to look at the treatment afforded persons who, like plaintiff, are enmeshed in and subject to the criminal justice system. Defendants do not claim a rational basis exists as to the different treatment accorded plaintiff and other persons in the criminal justice system in transferring them to a mental health facility, and we find that none exists.
Harmon v. McNutt, 91 Wn.2d 126, 130, 587 P.2d 537 (1978). The equal protection clause requires that persons similarly situated with respect to the legitimate purposes of the laws receive like treatment. McNutt, at 130.
Both Knapp and Wallin were found guilty of violating the criminal law and the trial courts in each case determined that they were in need of treatment for mental health problems which led to their criminal behavior. Yet the Legislature has granted one petitioner, Wallin, credit for the time spent in "treatment", RCW 71.06.020, while the other petitioner, Knapp, is denied credit for essentially the same custodial confinement. Neither respondent effectively addresses this disparate treatment; and we discern no difference between the petitioners meriting this distinction in treatment.
More importantly, the Legislature has recognized that persons sent to prison and then transferred to a state hospital for "observation, diagnosis or treatment" should be given credit for their time confined in the treatment facility. RCW 72.68.031. Neither respondent addresses the dissimilar treatment of persons initially sent to prison and *474 then sent to a state mental hospital for treatment, and persons initially sent to a state hospital for treatment, as a sexual psychopath or as a condition of probation, and then subsequently sent to prison. Both groups are sent to the hospital for "treatment" and not "punishment" yet the former group receives full sentence credit for their hospital time while the latter group, under the State's analysis, would be denied the same credit. There is no logical reason for distinguishing between persons who are transferred to mental health facilities after confinement in prison and persons originally sent to mental health facilities by the sentencing court prior to confinement in prison. State v. McCarter, 91 Wn.2d 249, 256, 588 P.2d 745 (1978).
Additionally, neither respondent addresses why pretrial and presentence hospital time is credited, Reanier v. Smith, 83 Wn.2d 342, 517 P.2d 949 (1974), but posttrial hospital time is not credited. In re Phelan, 97 Wn.2d 590, 595, 647 P.2d 1026 (1982) rejected any distinction between presentence and postsentence incarceration and that principle is applicable here. These distinctions in treatment do not withstand an equal protection challenge. If the Legislature recognizes that one member of the class should receive credit the equal protection clause mandates that all members should receive credit.

III
A more fundamental flaw in the respondents' position is that the petitioners are similarly situated to probationers sent to jail.[4] The Legislature has determined that custodial confinement in a state mental hospital is substantially synonymous with custodial confinement in prison or jail and that individuals incarcerated in the former should be *475 treated the same as those incarcerated in the latter. See, e.g., RCW 72.68.031.
Both groups, pursuant to their valid criminal convictions have been incarcerated in state institutions and are under the custody of state authorities. The distinction urged by the State ignores the fact that, like confinement in a prison or jail, a person committed to a mental hospital pursuant to a valid criminal conviction is subject to a massive curtailment of liberty. State v. Rinaldo, 98 Wn.2d 419, 425, 655 P.2d 1141 (1982). Like probationers incarcerated in jail, probationers confined in state hospitals are not free to leave the facilities. Neither petitioner in this case could request to leave the state hospital and by that request be allowed to leave. Cf. RCW 71.05.050 (any person voluntarily admitted for inpatient treatment shall be released immediately upon his request).
Furthermore, the distinction the State attempts to draw between jail time and nonjail time is not that clear. The respondents concede that petitioner Wallin's 90-day observation period is synonymous with jail time for crediting purposes. However, they argue that the subsequent "treatment period" is not analogous to jail time because it is devoid of "retribution". The respondents fail to articulate what characteristics of the observation period, which otherwise make it retributive and extremely analogous to jail time, are not present in the treatment stage. The Legislature has found no difference between the observation, diagnosis, or treatment period. See RCW 72.68.031. Similarly, on this record, we cannot discern a meaningful difference between the observation/diagnosis and treatment periods.
The respondents argue that even if the petitioners are similarly situated to those who serve probation "jail time", the distinction in treatment vis-a-vis credit serves a substantial state interest: rehabilitation of offenders in need of medical care. Purportedly, the denial of credit serves this interest by encouraging convicted individuals to make a good effort at completing their treatment programs. We find the petitioners' position to be more persuasive. To *476 deny credit will actually impede the State's interest in rehabilitation. Convicted offenders in need of mental health treatment would have no incentive to seek inpatient treatment, knowing that if they fail, they will not receive sentence credit for the time they are confined and in the custody of state authorities.
The respondents' position is undercut by the fact that the Board can consider the person's progress and effort at rehabilitation in setting his or her minimum discretionary term. The Board can consider an individual's good faith efforts at rehabilitation in setting a lower minimum discretionary term. Conversely, the Board can set a minimum discretionary term above the guideline range if the offender makes a bad faith effort at rehabilitation. See WAC Title 381, at 2024 (Supp. 1981-82). In light of this fact, we find the Board's arguments less than persuasive.
In sum, to adopt the respondents' position would lead to a highly anomalous result. Offenders in need of mental health help, who are held in custodial confinement at a state institution during their probation, would receive no credit toward their subsequently imposed prison sentence. However, offenders in need of mental health help due to sexual psychopathy, who are held in custodial confinement at a state institution prior to serving their prison term, would receive sentence credit but only toward their maximum term. Finally, offenders in need of mental health help, for any mental illness, who are first sent to prison and then transferred and held in custodial confinement at a state institution, would receive full credit toward both their discretionary minimum and maximum term.
Reanier v. Smith, 83 Wn.2d 342, 517 P.2d 949 (1974) and its progeny recognize that the equal protection clause requires that, for crediting purposes, all similarly situated individuals must be treated equally. Therefore, the petitioners must be given credit against all aspects of their prison sentences under the equal protection clause.
We, therefore, remand these cases to the Board for recalculation of the petitioners' discretionary minimum and *477 mandatory maximum terms. The Board's judgment and proceedings must reflect credit for the time both petitioners spent in custodial confinement at Eastern State Hospital.
WILLIAMS, C.J., ROSELLINI, UTTER, DOLLIVER, DORE, DIMMICK, and PEARSON, JJ., and CUNNINGHAM, J. Pro Tem., concur.
NOTES
[1]  RCW 71.06.120 reads:

"Time served by a sexual psychopath in a state hospital shall count as part of his sentence whether such sentence is pronounced before or after adjudication of his sexual psychopathy."
[2]  RCW 72.68.031 reads:

"When, in the judgment of the secretary, the welfare of any person committed to or confined in any state correctional institution or facility necessitates that such person be transferred or moved for observation, diagnosis or treatment to any state institution or facility for the care of the mentally ill, the secretary, with the consent of the secretary of social and health services, is authorized to order and effect such move or transfer: Provided, That the sentence of such person shall continue to run as if he remained confined in a correctional institution or facility, and that such person shall not continue so detained or confined beyond the maximum term to which he was sentenced: Provided, further, That the secretary and the board of prison terms and paroles shall adopt and implement procedures to assure that persons so transferred shall, while detained or confined at such institution or facility for the care of the mentally ill, be provided with substantially similar opportunities for parole or early release evaluation and determination as persons detained or confined in the state correctional institutions or facilities." (Italics ours.)
[3]  The respondents assert that RCW 71.06.120 is limited to the maximum sentence pronounced by the sentencing court and does not include the discretionary minimum term pronounced by the Board. We do not agree. Cf. Lindsey v. Superior Court, 33 Wn.2d 94, 204 P.2d 482 (1949) (statute addressing credit for sentence imposed by superior court includes credit for minimum discretionary term set by the Board of Prison Terms and Paroles). Absent a legislative indication to the contrary, we refuse to construe a statute in a manner that would treat offenders in need of treatment for sexual psychopathy differently depending upon whether they went to prison before as opposed to after their treatment. Cf. RCW 72.68.031; State v. McCarter, 91 Wn.2d 249, 256, 588 P.2d 745 (1978) (no logical reason for treating prisoners transferred from prison differently than offenders sent directly to a mental hospital by the sentencing court).
[4]  Contrary to the respondents' position in oral argument, our opinion will not limit the trial court's discretion in matters of probation. RCW 9.95.210 specifically limits probationary jail terms to 1 year. This opinion will not similarly limit probationary hospital time to 1 year because we are not holding that the word "jail" in RCW 9.95.210 incorporates state hospitals. Nothing in this opinion should be construed to reach that or a similar result.
