
45 P.3d 329 (2002)
STATE of Alaska, Appellant,
v.
Norman R. JUDSON, Appellee.
No. A-8050.
Court of Appeals of Alaska.
April 12, 2002.
*330 Kim S. Stone, Assistant Attorney General, Office of Special Prosecutions and Appeals, Anchorage, and Bruce M. Botelho, Attorney General, Juneau, for Appellant.
Thomas G. Nave, Juneau, for Appellee.
Before: COATS, Chief Judge, and MANNHEIMER and STEWART, Judges.

OPINION
COATS, Chief Judge.
After pleading guilty to driving while intoxicated (DWI),[1] Norman R. Judson asked the district court to order him, as a condition of his release, to enroll in residential alcohol treatment in Washington state. The court agreed and at sentencing granted Judson twenty-one days of confinement credit enough to satisfy the statute's twenty-day mandatory minimum sentence for second offendersfor the time he spent in alcohol treatment.
The state argues that the court erred by awarding Judson Nygren credit[2] for the time he spent in treatment because the court's order mandating treatment was not a true court order, but an accommodation of Judson's desire to avoid jail. The state also argues that Nygren credit cannot be used to satisfy the DWI statute's mandatory minimum sentence because the legislature intended jail time and rehabilitative treatment to be distinct requirements. Lastly, the state argues that the district court violated the bail release statute by ordering treatment without considering whether Judson was a flight risk or a danger to the community. We reject these three claims and affirm Judson's sentence.

Facts and proceedings
On March 6, 2001, Judson was cited for DWI. He was released on his own recognizance. A month later, Judson pleaded guilty to DWI and asked District Court Judge Peter B. Froehlich to modify his conditions of release to require him to enroll in the Sundown M Ranch, an alcohol treatment program in Washington. Judson asked for this order so he would be eligible at sentencing to request Nygren credit for the days he was confined to treatment. The state opposed Judson's request, arguing that accommodating Judson's desire to serve his sentence in alcohol treatment instead of jail, as opposed to ordering treatment as part of his sentence, would violate equal protection, the bail and DWI statutes, and Nygren requirements.
*331 The district court rejected the state's arguments and granted Judson's request. Judge Froehlich conceded that the only changed circumstance that would warrant modification of Judson's release conditions was his DWI conviction. But Judge Froehlich noted that Judson's conviction was a "significant change." Judge Froehlich also reasoned that Judson would receive longer-lasting benefits from alcohol treatment than time in a jail cell, the community would benefit from Judson's rehabilitation, and the state would save money.
During Judson's sentencing hearing in June, the state reiterated its arguments in opposing Nygren credit for the time Judson had spent in treatment. The state also argued that the Sundown M Ranch was not restrictive enough to meet Nygren requirements. After hearing testimony from a representative of that treatment program, Judge Froehlich concluded that Judson was entitled to twenty-two days of Nygren credit for the time he had spent in treatment (twenty-one days) and in jail (one day). Judge Froehlich then sentenced Judson to 122 days with 100 suspended and placed him on probation for three years. Judson's conditions of probation required him, among other things, to be screened by the Alcohol Safety Action Program (ASAP) and to complete up to forty-five days of inpatient treatment if recommended by that program.
The state appeals the district court's decision to grant Nygren credit, but does not argue on appeal that the Washington facility failed to meet Nygren requirements.

Discussion


Should Judson get Nygren credit for the period he spent in treatment even though he asked the court to order him to participate in treatment?

The crux of the state's argument is that Judson should not receive Nygren credit for the period he spent in alcohol treatment because the court's order was "nothing more than an accommodation of Judson's desire to get treatment and avoid serving time in jail." Under Nygren v. State, a defendant can receive credit for time served in treatment if the defendant is subjected to "restrictions approximating incarceration."[3]
The state relies on Anchorage v. Bussell[4] to argue that Judson's treatment was insufficiently compelled to entitle him to Nygren credit. In Bussell, we held that the defendant could not receive credit toward his sentence for time he had spent in treatment before reporting to jail because the court had never issued a valid order mandating that treatment.[5] We observed that time voluntarily spent in a restrictive treatment environment does not automatically entitle a defendant to credit for time served.[6] Here, the state does not dispute that the district court issued an order requiring treatment, but argues that the order was invalid because it was issued at Judson's request and on Judson's schedule.
We recently reaffirmed the Bussell holding in State v. Fortuny.[7] In Fortuny, the defendant enrolled in residential alcohol treatment while awaiting sentencing for DWI and third-degree assault.[8] After Fortuny had spent about six weeks in that program, the court ordered Fortuny to continue alcohol treatment, presumably at his request.[9] We held that Fortuny could receive Nygren credit for the days he spent in treatment after the court issued its order, but not before.[10] The state did not argue, as it does here, that the court's order was invalid because it accommodated Fortuny's voluntary decision to enroll in treatment. Consequently, the issue raised by this appeal was never litigated.
Because we have never held that Nygren credit is inappropriate in Judson's circumstances, the state relies by analogy on our *332 decision in M.R.S. v. State.[11] The defendant in M.R.S. asked the court to order him as part of a delinquency proceeding to undergo a psychological evaluation.[12] In a later unrelated proceeding, M.R.S. argued that the statements he made in that evaluation were protected from disclosure by the privilege against self-incrimination because they were obtained by government compulsioni.e., by court order.[13] We rejected that claim, finding the statements voluntary because the psychological evaluation had been conducted "at M.R.S.'s behest and with his blessing[.]"[14] The state asserts that this same principle applies here, arguing that "Judson's days at the rehabilitation center cannot be deemed court-ordered: the `confinement' was voluntary, rather than compelled, because the `order' was done strictly at Judson's behest."
The state's analogy is unpersuasive. For purposes of receiving Nygren credit for time spent in a treatment facility, the significant question is not whether the treatment was ordered at the defendant's behest or against his will, but the extent to which the defendant "is subjected to restrictions approximating those experienced by one who is incarcerated."[15] A defendant who voluntarily enters a treatment program is not subjected to jail-like conditions because the defendant can leave the program at any time. But once a defendant is under court order to attend treatment, that defendant faces immediate arrest and imprisonment for leaving the facility without court permission.[16]
To support its argument that Judson's enrollment in treatment was voluntary despite the court order, the state speculates that Judge Froehlich would have excused Judson from the treatment program if Judson had changed his mind. But even if Judson had persuaded the court to release him from treatment, Judson would only be eligible for Nygren credit for the days he actually spent in the treatment program under court order, and he would face the prospect of a harsher ultimate sentence that reflected his more doubtful prospects for rehabilitation. Judson's enrollment in treatment under court order thus cannot be equated with the voluntary participation we discussed in Bussell and Fortuny.
The significant issue under Nygren is not whether the defendant asks for treatment, but whether the defendant is subjected to jail-like conditions during treatment. The state does not dispute that the treatment facility Judson attended met Nygren requirements. We therefore conclude that Judson was entitled to Nygren credit for the time he spent in treatment even though the treatment was ordered at Judson's request.


Can Nygren credit for alcohol treatment satisfy the minimum jail time requirement in the DWI statute?

As a second DWI offender, Judson was subject to a mandatory minimum sentence of twenty days.[17] Judge Froehlich sentenced Judson to 122 days with 100 suspended after awarding him 22 days of confinement credit for the time he had spent in treatment and in jail. The state argues that this sentence thwarted the legislature's intent to require both mandatory imprisonment and alcohol treatment for DWI offenders.
We agree that the mandatory minimum sentence and alcohol screening and referral are distinct requirements of the DWI statute.[18] But the state's argument that Judson *333 cannot use Nygren credit to satisfy his twenty-day mandatory jail term because the legislature intended courts to impose both jail time and treatment overlooks two important points. First, although alcohol screening and referral are mandated by the statute, inpatient alcohol treatment is not.[19] Second, inpatient treatment at a facility that meets Nygren requirements "is the functional equivalent of jail time and therefore constitutes a sentence of imprisonment."[20] Indeed, substituting inpatient treatment for jail time in some cases will result in a longer period of custody, because jail inmates get good time credit.[21] Here, Judson spent twenty-one days in a treatment program that met stringent Nygren requirements, as opposed to fourteen days he would have spent in jail if the court had imposed the minimum twenty-day sentence and Judson had accumulated the usual amount of good time credit.[22]
In addition to imposing a sentence in excess of the twenty-day minimum, Judge Froehlich placed Judson on probation for three years and required him to complete any treatment recommended by the Juneau ASAP, including up to forty-five days of inpatient treatment. Thus, the court imposed just the type of sentence envisioned by the legislature for a second DWI offender: at least twenty days in a jail-like environment, alcohol screening and referral, and additional treatment if circumstances required.
The history of the DWI statute leads us to conclude that the legislature intended to give courts this broad latitude to order inpatient treatment for DWI offenders. In 1990, the legislature amended the DWI and sentencing statutes to ensure that courts could require rehabilitative treatment as a condition of probation or incarceration.[23] These amendments were enacted in response to decisions of this court and the supreme court that recognized then-existing limits on the power of courts to order such treatment.[24]
We conclude that the district court had authority to apply the Nygren credit Judson had earned in residential alcohol treatment toward his twenty-day mandatory minimum sentence. Time spent at a treatment facility that meets Nygren requirements is the equivalent of incarceration. Moreover, the legislature has clearly conferred authority on the courts to order residential treatment where appropriate for DWI offenders.

Did the court violate the bail statute by changing Judson's conditions of release without considering the proper statutory factors?
The state next argues that the district court failed to consider the proper statutory factors before modifying Judson's conditions of release to order him to participate in residential treatment. The bail release statute, AS 12.30.020, requires courts to release a person charged with an offense on that person's personal recognizance or on the posting of bail unless that person has been convicted of certain serious offenses or the court determines that release will pose a danger to the community or will not reasonably *334 assure the accused's appearance in court.[25] Once such a determination is made, the statute authorizes the court to impose a variety of bail release conditions.[26] The state argues that the court erred when it ordered Judson to attend treatment for a reason not authorized by the bail statute: so he could get Nygren credit.
As a preliminary matter, we note that the district court ordered Judson into treatment after he had pleaded guilty to DWI. Consequently, the court's order was governed by AS 12.30.040, which regulates a defendant's release after conviction, not by the bail release statute. However, AS 12.30.040 requires the court to consider the same statutory factors before imposing conditions of release.[27]
Although Judge Froehlich never expressly addressed these statutory factors, he did note that Judson's conviction was a "significant change" in circumstances that could warrant release conditions different from those the court imposed before Judson changed his plea. Nevertheless, we assume for the sake of argument that Judson's DWI conviction was an inadequate basis under AS 12.30.040 for the court to order Judson into alcohol treatment to protect the public. Even so, we reject the state's claim that the court's order violated the bail statute (or AS 12.30.040) because the court had no duty to consider whether Judson was a flight risk or a danger to the community before ordering alcohol treatment at Judson's request. The requirement that courts base release conditions on these two factors is aimed at protecting the accused from needless detention, not at preventing courts from imposing more stringent bail conditions that the defendant invites. When the bail statute was enacted in 1966, its avowed purpose was to "assure that all persons, regardless of their financial status, shall not needlessly be detained pending their appearance to answer charges[.]"[28] Initially, the statute authorized courts to impose conditions on a defendant's release only if necessary to ensure that the defendant appeared in court.[29] Since then, the statute has been amended to allow courts to consider a defendant's potential danger to the community, the alleged victim, or others.[30] But none of these changes suggests that the underlying purpose of the statuteprotecting the accused from being needlessly detainedhas changed.
Because the requirement that courts base release conditions on the defendant's flight risk and potential danger is aimed at protecting the defendant, we conclude that AS 12.30.020 imposes no duty on courts to consider these specific factors before imposing a rehabilitative condition that the defendant requests.

Conclusion
The judgment of the district court is therefore AFFIRMED.
MANNHEIMER, Judge, concurring.
I join the majority's decision with some reluctance. I agree with all the legal premises discussed in the majority opinion, but I am troubled by the consequences of our decision.
When the Alaska legislature amended AS 12.55.025(c) to give defendants "credit for time served", the legislature was pursuing the aim of equal treatment among rich and poor. That is, the legislature wanted to make sure that an indigent defendant who could not secure bail release (and who therefore *335 remained in jail while awaiting trial) would not be forced to serve more total time in jail than another defendant who remained free pending trial and who then received the same sentence.
In Nygren v. State[1], this court expanded the concept of "credit for time served" when we held that AS 12.55.025(c) was not limited to defendants who spent time in jail before conviction, but rather applied to all defendants who were confined by court order to a jail-like residential facility while awaiting trial and sentencing.
We are now confronted with an instance in which a defendant took strategic advantage of our Nygren decision by asking the trial court to order him to stay in a residential treatment facility while he awaited sentencing. I agree with my colleagues that this was legal and that the defendant was entitled to claim credit against his eventual sentence for the days he spent in the treatment facility. But our decision holds disquieting consequences.
Now that we have decided that Nygren credit is available to defendants who ask the trial court to order them into residential treatment, I fear that defendants may again be divided into rich and poor. Defendants who can afford the expense of a residential treatment facility will ask the court to place them therewith the result that these defendants will effectively serve their sentences in treatment facilities (for they will receive credit for the days spent there). Poorer defendants, on the other hand, will serve their sentences in jail.
It is hard to fault the trial judge for ordering Judson to engage in residential treatment for twenty days rather than having him sit in jail for twenty days. Presumably, society is better off whenever a defendant receives active treatment while in custody. And if a defendant is willing and able to pay for their own treatment, so much the better. But unless our government makes a real effort to provide treatment alternatives for defendants with less money, we in Alaska may have to get used to seeing the same type of story that intermittently appears in the media when movie stars or sports celebrities are charged with a crime involving substance abuse: the rich and the famous go to treatment centers, while other defendants go to prison.
NOTES
[1]  AS 28.35.030(b)(1)(B).
[2]  See Nygren v. State, 658 P.2d 141, 146 (Alaska App.1983).
[3]  658 P.2d at 146.
[4]  702 P.2d 667 (Alaska App.1985).
[5]  Id. at 668-69.
[6]  Id. at 669.
[7]  42 P.3d 1147, (Alaska App.2002).
[8]  Id. at 1148.
[9]  Id. at 1149.
[10]  Id. at 1149-1152.
[11]  867 P.2d 836 (Alaska App.1994), rev'd on other grounds, 897 P.2d 63 (Alaska 1995).
[12]  Id. at 838-39.
[13]  Id.
[14]  Id. at 839.
[15]  Nygren, 658 P.2d at 146; see also State v. Crosby, 770 P.2d 1154, 1157 (Alaska App.1989) ("The right to receive credit for time served arises when a defendant's liberty is substantially restricted by court order.").
[16]  See Nygren, 658 P.2d at 146.
[17]  See AS 28.35.030(b)(1)(B).
[18]  See AS 28.35.030(b)(1)(B) (mandating minimum sentence of twenty days for a second offender); AS 28.35.030(h) (requiring the court to order all DWI offenders to satisfy the screening, evaluation, referral, and program requirements of an Alcohol Safety Action Program or other approved treatment facility); AS 28.35.030(i) (providing that inpatient treatment may be required by an authorized agency only if authorized in the judgment).
[19]  See AS 28.35.030(i).
[20]  Dodge v. Anchorage, 877 P.2d 270, 272 (Alaska App.1994) (citing Lock v. State, 609 P.2d 539 (Alaska App.1980)); cf. Hester v. State, 777 P.2d 217, 219 (Alaska App.1989) (addition of thirty-day inpatient treatment requirement not designated in the judgment violated the double jeopardy clause because the defendant was subjected to restraints equivalent to custody).
[21]  See Parker v. State, 714 P.2d 802, 806 (Alaska App.1986).
[22]  See AS 33.20.010.
[23]  See ch. 188, §§ 1-5, 7, SLA 1990; January 19, 1990, Sectional Analysis of H.B. 366; note 24, infra.
[24]  See House Judiciary Committee hearing on H.B. 366 (January 24, 1990) (testimony by Laurie Otto, Assistant Attorney General); Memorandum on H.B. 366 from Rep. Fran Ulmer to the House Judiciary Committee (January 17, 1989); Memorandum on H.B. 366 from Rep. Fran Ulmer to the Democratic Caucus (December 5, 1989); Letter from the Department of Law to Rep. Ulmer on the questionable authority of courts to order treatment for incarcerated offenders and as a condition of probation following the decisions in Boyne v. State, 586 P.2d 1250 (Alaska 1978), Hester v. State, 777 P.2d 217 (Alaska App.1989), and Benboe v. State, 738 P.2d 356 (Alaska App.1987) (November 17, 1989).
[25]  See AS 12.30.020(a).
[26]  See AS 12.30.020(b).
[27]  AS 12.30.040 provides in relevant part:

Release after conviction. (a) A person who has been convicted of an offense and is awaiting sentence, or who has filed an appeal, shall be treated in accordance with the provisions of AS 12.30.020 unless the court has reason to believe that no one or more conditions of release will reasonably assure the appearance of the person as required or prevent the person from posing a danger to the victim, other persons, or the community. If that determination is made, the person may be remanded to custody.
[28]  Report of the House Judiciary Committee on H.B. 317, 1966 House Journal 110-11.
[29]  See ch. 20, § 1, SLA 1966.
[30]  See ch. 112, §§ 1, 2, SLA 1967; ch. 39, § 1, SLA 1974; ch. 143, § 16, SLA 1982; ch. 63, §§ 10, 11, SLA 1997.
[1]  658 P.2d 141 (Alaska App.1983).
