
564 N.W.2d 616 (1997)
1997 ND 102
Shawn Allen OSTAFIN, Petitioner and Appellee,
v.
The STATE of North Dakota, Respondent and Appellant.
Criminal No. 960243.
Supreme Court of North Dakota.
June 3, 1997.
Allen M. Koppy (argued), State's Attorney, Mandan, for respondent and appellant.
Ross H. Espeseth (argued), LaRoy Baird, P.C., Bismarck, for petitioner and appellee.
MARING, Justice.
[¶ 1] The State appeals from an order granting Shawn Ostafin's motion to correct an illegal sentence on the ground that his waiver of any "good time" earned was illegal. We affirm the district court's order that the original sentence was illegal, reverse that portion of the order allowing the withdrawal *617 of the guilty plea, and remand for re-sentencing.
[¶ 2] On November 8, 1991, Shawn Ostafin entered pleas of guilty for the murders of his father, Roger Ostafin, and his step-mother, Rosemary Ostafin, both Class AA felonies. In accordance with a plea agreement, Ostafin was sentenced to serve two concurrent 17 year sentences at the State Penitentiary and waived any reduction in sentence for "good time" or good conduct under N.D.C.C. § 12-54.1-01. As a result, Ostafin's sentence was a definite 17 years. The plea agreement, dated November 8, 1991, was in writing and signed by the State's Attorney, the defense attorney and Shawn Ostafin.[1]
[¶ 3] Ostafin filed a motion to correct an illegal sentence with the District Court of Morton County on March 28, 1996, which the State resisted. Counsel was appointed to represent Ostafin, and a hearing on the matter was held on August 25, 1996. At the hearing, Ostafin argued this Court's decision in State v. Trieb, 516 N.W.2d 287 (N.D.1994) (Trieb II) was controlling, and as such, Ostafin's waiver of good time credits rendered his 1991 plea agreement illegal, resulting in an illegal sentence. Agreeing with Ostafin's position that the sentence was illegal, the trial court gave Ostafin two choices: (1) withdraw his guilty plea and stand trial, or (2) continue the guilty plea and permit the judge to correct the sentence. Ostafin chose to withdraw his guilty plea. The State appeals from the court's order issued on August 26, 1996, and dated October 1, 1996, permitting Ostafin to withdraw his plea of guilty.
[¶ 4] In his motion to correct an illegal sentence under Rule 35(a), N.D.R.Crim.P., Ostafin sought correction of the sentence so he could "collect all back, present, and future good time." Ostafin's motion did not request a withdrawal of his guilty plea. In response to the motion, the trial court interpreted Trieb II as requiring the court to offer a defendant the option of either withdrawing the guilty plea or asking the court to correct the illegal sentence. At the hearing on the motion, Ostafin indicated he would like to withdraw his guilty plea. We take this opportunity to clarify our decisions in Trieb II and State v. Trieb, 533 N.W.2d 678 (N.D. 1995) (Trieb III).

I
[¶ 5] In Trieb II, this court held both the original sentence and the amended sentence were illegal sentences because a defendant cannot waive good time credits. Trieb, 516 N.W.2d at 291. This court stated: "[t]he sentencing court was outside its jurisdiction when it, in effect, guaranteed good time on a 30 year sentence by sentencing Trieb to 22 years, while placing limitations on accrual and application of good time." Id. at 292. This court reasoned the deduction of good time credits from a sentence is a matter not within the discretion of the courts, but within the discretion of the penitentiary administration to encourage good conduct of prisoners. The legal maxim, "a law established for a public reason cannot be contravened by a private agreement," supports our decision that a defendant cannot waive a right the legislature has given to prison administration to utilize for the purpose of inducing good behavior in prison. N.D.C.C. § 31-11-05(4). Further, there can be no waiver of statutory rights if such waiver would be against public policy. N.D.C.C. § 1-02-28. The legislative purpose of good time is to improve prison behavior and thereby improve overall prisoner morale and well being.
[¶ 6] The State urges this court to overrule its decision in Trieb II. The State, however, does not present any arguments not presented and decided in Trieb II. We are unpersuaded and affirm our decision in Trieb II.


*618 II
[¶ 7] The State next argues the sentence given in Ostafin is distinguishable from the illegal sentence given in Trieb II, because Ostafin's sentence, unlike Trieb's sentence, neither approaches the threshold of a potential life sentence nor prohibits eligibility for parole. The State contends, because of these different facts, Trieb II does not apply to this case. Despite these differences in the sentences, however, the Ostafin sentence is still illegal under Trieb II because the sentence allowed the defendant to waive good time reduction in his sentence by plea agreement. A penitentiary prisoner must "earn" the monthly reductions for the sentence being served by "good conduct." The statute does not authorize a prisoner to automatically "earn good time" by entering into a plea agreement. N.D.C.C. § 12-54.1-01. Our decision in Trieb II applies to this case, and we affirm the trial court's determination that the sentence in State of North Dakota v. Shawn Allen Ostafin, Case No. 91-K-3235 was an illegal sentence.

III
[¶ 8] Finally, the State argues the trial court had the discretion to amend the sentence to correct it in such a manner so as to maintain the intent of the original plea bargain. We agree.
[¶ 9] In Trieb II, this court remanded the case to the trial court "to amend the sentence to allow for good time, or to allow Trieb to withdraw his guilty plea." Trieb, 516 N.W.2d at 292 (emphasis ours). The trial court, instead of exercising its right to correct the illegal sentence, gave Trieb his choice and Trieb chose to continue his guilty plea. The trial court then re-sentenced him to thirty years, and allowed for good time credits, which, in effect, would result in a sentence of 22 years. At the sentencing hearing the trial court clarified that all parties understood "the sentence of 22 years is the equivalent of the 30 year requirement of the statute." Trieb, 516 N.W.2d at 290.
[¶ 10] In Trieb III, this court was faced with the issue of whether the trial court's sentence of Trieb on remand to thirty years in the state penitentiary with credit for time served and reinstatement of good time credit at the discretion of the entities granting the credit was within the intent of the original plea bargain. State v. Trieb, 533 N.W.2d 678 (N.D.1995). We stated: "the re-sentencing of Trieb to thirty years with the allowance of good time maintains the intent of the original plea bargain." Id. at 681. We thus concluded the amended sentence was within the clear intent of the original plea bargain given the evidence in the transcript of the original sentencing hearing and the text of the sentence. Id.
[¶ 11] In Trieb III, this court summarized two schools of thought on the right of the sentencing court to correct an illegal sentence under Rule 35(a), N.D.R.Crim.P.[2]State v. Trieb, 533 N.W.2d 678, 680-81 (N.D.1995) (quoting Christopher Vaeth, Annotation, Guilty Plea as Affected by Fact That Sentence Contemplated by Plea Bargain Is Subsequently Determined to Be Illegal or Unauthorized, 87 A.L.R.4th 384, 388 (1991)). The majority of states allow the defendant to withdraw a guilty plea if it is subsequently determined the sentence is illegal. Id. Some jurisdictions, however, have determined that "`providing the defendant with an opp[o]rtunity (sic) to withdraw the [guilty] plea may be unnecessary if the illegal sentence can be reconciled with the plea bargain or otherwise corrected so as to give the defendant the benefit of the bargain'." Id., see, e.g., State v. Gourdin, 156 Ariz. 337, 751 P.2d 997 (Ariz.App.1988); Matter of Williams, 21 Wash.App. 238, 583 P.2d 1262 (1978). In Trieb III, Trieb chose to continue in his guilty plea and did not seek its withdrawal. Thus, this court did not embrace a particular school of thought to follow when defendant's withdrawal of a plea may be unnecessary because the illegal sentence can be corrected so as to provide the defendant with the intent of the original plea bargain.
*619 [¶ 12] In Trieb III, we held a sentencing court can correct an illegal sentence at "any time" under Rule 35(a), N.D.R.Crim.P. and can do so generally even if the correction results in a harsher sentence. Id. at 680; see also Rule 35(a), N.D.R.Crim.P. We pointed out in State v. Nace, 371 N.W.2d 129, 131 (N.D.1985), "American jurisprudence has a long history of correcting illegal or excessive sentences...." We have held correction of an illegal sentence involves a substantial right and an order denying correction of an illegal sentence is appealable. Nace, 371 N.W.2d at 131; State v. Gunwall, 522 N.W.2d 183 (N.D.1994).
[¶ 13] We do not analyze this case as a motion to withdraw a guilty plea under Rule 32(d), N.D.R.Crim.P. which states in part:
(1) The court shall allow the defendant to withdraw a plea of guilty whenever the defendant, upon a timely motion for withdrawal, proves that withdrawal is necessary to correct a manifest injustice.
Ostafin did not move to withdraw his plea of guilty under Rule 32(d), but rather moved to correct an illegal sentence specifically under Rule 35(a). Ostafin did not request he be allowed to withdraw his plea of guilty, but rather asked for a correction of his sentence so he could "collect all back, present and future good time." Ostafin represented himself when he brought his motion, but had court appointed counsel at the motion hearing. He has never argued he should be allowed to withdraw his guilty plea "to correct a manifest injustice" under Rule 32(d)(1), N.D.R.Crim.P. We, therefore, do not examine this case under Rule 32(d) or precedent analyzing what criteria establish "a manifest injustice" thereunder.
[¶ 14] As previously noted, we upheld the trial court's resentence of Trieb because the sentence "maintain[ed] the intent of the original plea bargain." Trieb, 533 N.W.2d at 681 (N.D.1995).
[¶ 15] We conclude when a defendant brings a motion to correct an illegal sentence under Rule 35(a), N.D.R.Crim.P., the sentencing court should first determine whether the illegal sentence can be corrected in such a manner so as to preserve the intent of the original plea agreement and give the defendant that for which he bargained.[3] Only if such modification of the original sentence cannot be done, should the defendant be given the opportunity to withdraw his guilty plea.
[¶ 16] Ostafin agreed to and expected to receive a determinate 17 year prison sentence in consideration of his waiver of "good time" reduction of his sentence. The sentencing court must modify the sentence to allow Ostafin to earn "good time" credits under N.D.C.C. § 12-54.1-01, but still serve two concurrent terms at least equal to the previously agreed upon 17 years. The corrected sentence must be reconciled with the intent of the plea agreement. If this cannot be accomplished, then the sentencing court must give Ostafin the opportunity to withdraw his guilty plea or persist in his guilty plea and be re-sentenced by the sentencing court.
[¶ 17] We remand to the sentencing court to determine whether the illegal sentence can *620 be corrected so as to maintain the intent of the plea agreement and, if so, to re-sentence Ostafin consistent with our decision in Trieb III and this decision. Only if the court cannot modify the sentence to allow for "good time" and uphold the intent of the plea bargain, must Ostafin be allowed the opportunity to withdraw his guilty plea.
[¶ 18] VANDE WALLE, C.J., and MESCHKE, J., concur.
NEUMANN, Justice, specially concurring.
[¶ 19] I concur in the result. In fact, I concur in everything the majority says, as far as the opinion goes. I write separately because, in my opinion, the majority does not go far enough. The majority says the trial court, on remand, must attempt to modify Ostafin's sentence to allow for good time. I would hold the trial court must consider modifying the sentence, within the parameters of the original plea agreement, to allow for good time. However, if such a modified sentence is unacceptable to the trial court, the trial court may then exercise its authority under Rule 11(d)(4), N.D.R.Crim.P., by rejecting the plea agreement, as modified to allow for a legal disposition, and affording the defendant an opportunity to withdraw his plea.
[¶ 20] In my opinion, the trial court's error in this case was to completely ignore the plea agreement, and to proceed as if the agreement had been rejected, even though the court never stated on the record, as required by Rule 11(d), that it rejected the agreement. During the hearing on the motion to correct sentence, the trial court very correctly pointed out that in Trieb II this court reversed and remanded to the district court to amend Trieb's sentence to allow for good time, or to allow Trieb to withdraw his plea of guilty. But, a few moments later, before Ostafin's attorney had a chance to suggest how the sentence might be amended to allow for good time, the trial court stated: "Now I will say this, Mr. Espeseth, if you were prepared to argue that the defendant should get his 17 years but get credit for good time, that argument isn't going to get anywhere because if the sentence is illegal in part, it's all illegal," a statement clearly contrary to the instruction in Trieb II to amend the sentence to allow for good time.
[¶ 21] The majority attempts to correct the trial court's failure to consider the possibility of modifying the sentence, but the majority does not recognize all of the trial court's responsibility and authority under Rule 11(d), N.D.R.Crim.P. On reviewing Trieb II, I can easily understand how this might happen. The author of Trieb II, a trial judge of some years' experience, but a comparative neophyte at the appellate opinion-writing business, assumed the existence and effect of Rule 11(d) without explicitly mentioning it. Unfortunately, what had seemed as familiar as daily bread to the author has proven, under these circumstances, to be far less than apparent to anyone else. Because of my inarticulate assumption and oversight in Trieb II, I offer this belated effort to explain my understanding of the impact of Rule 11(d) when a trial court is called upon to correct an illegal sentence imposed as the result of a plea agreement.
[¶ 22] Rule 11(d)(3), N.D.R.Crim.P., says if a court accepts a plea agreement, "the court shall inform the defendant that it will embody in the judgment and sentence the disposition provided for in the plea agreement or another disposition more favorable to the defendant than that provided for in the plea agreement." Necessarily implicit in that requirement is the idea that if the court is going to impose a disposition less favorable than that provided for in the agreement, the court is obligated to reject the agreement. Rule 11(d)(4) says if a court is going to reject a plea agreement:
"[T]he court, on the record, shall inform the parties of this fact, advise the defendant personally in open court ... that the court is not bound by the plea agreement, afford the defendant the opportunity to then withdraw the plea, and advise the defendant that if the defendant persists in a guilty plea the disposition of the case may be less favorable to the defendant than that contemplated by the plea agreement."
[¶ 23] In Trieb II, after declaring the sentence embodied in the plea agreement to be *621 illegal, this author gave no further guidance, but simply wrote, "[w]e reverse and remand to the district court to amend the sentence to allow for good time, or to allow Trieb to withdraw his guilty plea." Trieb II, 516 N.W.2d at 292. Intended, but unstated, was the implication that any amendment of the sentence to allow for good time would have to be done under Rule 11(d)(3): it would have to provide for a disposition no less favorable to the defendant than that contained in the originaleven though illegalplea agreement. Also intended, but unstated, was the further implication that if an amendment to the sentence within the outer limits established by the original plea agreement would not be acceptable to the trial court, then the court could reject the modified version of the plea agreement under Rule 11(d)(4), advise the defendant of that fact, and afford him the opportunity to withdraw his guilty plea.
[¶ 24] In attempting to follow the cryptic instruction in Trieb II, the trial judge there, just like the trial judge in this case, chose not to attempt to amend the sentence to allow for good time, but went directly to step two and offered the defendant an opportunity to withdraw his plea of guilty. That oversight by the Trieb judge never became an issue in that case, because Trieb, after being fully advised of the potential consequences, including the possibility of a life sentence, persisted in his plea of guilty. The fact that the trial court never formally rejected the plea agreementor any possible disposition more favorable to the defendantwas never raised by Trieb as an issue in his third appeal.
[¶ 25] The difference here is that Ostafin has not persisted in his plea of guilty, but has withdrawn it, resulting in an appeal not by Ostafin, but by the State. Thus, the issue not raised in Trieb is now before us. I agree with the majority that the trial court should consider the possibility of honoring as much of the original plea agreement as possible before offering the defendant an opportunity to withdraw his plea. I also suggest, however, we cannot require the trial court to abide by Rule 11(d)(3) without also providing the court the option under Rule 11(d)(4) of rejecting the new disposition that may result under the plea agreement. If the trial court is to assume the responsibility under Rule 11(d)(3) of imposing a sentence that, in order to be legal, may have to be more favorable to the defendant than the disposition provided in the original plea agreement, then the trial court must also have the opportunity under Rule 11(d)(4) to reject that agreement if the resulting legal disposition proves to be an inadequate punishment for the offense committed.
[¶ 26] If the majority, by its omission, means to hold that the trial court must modify Ostafin's sentence to allow for good time, but does not have the authority to reject the proposed modified sentence by rejecting the underlying plea agreement, then the majority is overruling both Trieb II and Trieb III. In Trieb II, as already noted, we remanded to the trial court "to amend the sentence to allow for good time, or to allow Trieb to withdraw his guilty plea." Trieb III, 516 N.W.2d at 292. (Emphasis added.) In Trieb III the trial court declined to sentence Trieb under the plea agreement, and instead offered Trieb the opportunity to withdraw his plea. When Trieb rejected that opportunity and persisted in his plea of guilty, the trial court proceeded to resentence him, and we affirmed.[1]
[¶ 27] If this court's decisions in Trieb II and Trieb III are to stand, the majority's *622 opinion in this case must be read to require the trial court only to consider the possibility of resentencing Ostafin. The trial court must also still have the authority to reject the proposed new sentence, and if it does, to afford Ostafin the opportunity to withdraw his guilty plea. With the understanding the majority's opinion does not overrule Trieb II and Trieb III, I concur.
[¶ 28] William A. Neumann
SANDSTROM, Justice, dissenting.
[¶ 29] For the reasons set forth in my dissent in State v. Trieb, 516 N.W.2d 287, 292-94 (N.D.1994) (Sandstrom, J., dissenting), I dissent.
[¶ 30] The majority writes at ¶ 5:
"The legal maxim, `a law established for a public reason cannot be contravened by a private agreement,' supports our decision that a defendant cannot waive a right the legislature has given to prison administration to utilize for the purpose of inducing good behavior in prison. N.D.C.C. § 31-11-05(4). Further, there can be no waiver of statutory rights if such waiver would be against public policy. N.D.C.C. § 1-02-28. The legislative purpose of good time is to improve prison behavior and thereby improve overall prisoner morale and well being."
This analysis is seriously flawed for a number of reasons.
[¶ 31] The binding plea agreement in this case was not and is not a "private agreement." The plea agreement was a binding public agreement, provided for by judicial rule, N.D.R.Crim.P. 11(d), and specifically effective only on acceptance and approval of the appropriate public official, the trial judge.
[¶ 32] The majority's assertion as to our legislature's intent is, as in the progenitor opinion, wholly unsupported by reference to the legislative record, contrary to the specific prior holdings of this Court, Matz v. Satran, 313 N.W.2d 740, 742 (N.D.1981) (citing Wolff v. McDonnell, 418 U.S. 539, 94 S.Ct. 2963, 41 L.Ed.2d 935 (1974)) (a prisoner's right to statutory good time is a liberty interest protected by the Due Process Clause of the Fourteenth Amendment); Jensen v. Satran, 332 N.W.2d 222, 226 (N.D.1983) (a prisoner has a constitutionally protected right to good time), and inconsistent with the position of the prison officials' own attorney, the Attorney General, see letter opinion from Deputy Attorney General Calvin Rolfson to the Director of the North Dakota Department of Parole and Probation of February 1985 (prisoner can bargain away statutory right to good time).
[¶ 33] The majority's assertion that waiver of a statutory right to good time is contrary to public policy is unsupported by a public policy or by logic. Clearly, criminal defendants have a general right to waive their rights. State v. Wilson, 488 N.W.2d 618, 620 (N.D.1992). Thus, there is nothing contrary to public policy in allowing an inmate to waive his rights. What public policy says an inmate, having waived his own right, should be entitled to assert a right of prison administrators? There is none.
[¶ 34] This does not mean the prison administrators could not assert their own rights regarding a sentence; they can. See State ex rel. Olson v. Maxwell, 259 N.W.2d 621, 629 (N.D.1977) (supervisory writ sought relating to sentence.)
[¶ 35] Ostafin bargained away his right to good time and has no standing to assert the rights of prison administrators. I would reverse and reinstate Ostafin's sentence.
[¶ 36] Dale V. Sandstrom
NOTES
[1]  The terms of the plea agreement were as follows:

"1. That the Defendant will be sentenced to serve a term of seventeen (17) years at the North Dakota State Penitentiary on each of the two charges of murder.
2. That those sentences shall be served concurrently.
3. That the Defendant's sentence shall not be reduced for "good conduct" under section 12-54.1-01 NDCC.
4. That the Defendant shall receive credit for time served since December 1, 1990."
[2]  Rule 35(a), N.D.R.Crim.P. states:

"(a) Correction of Sentence. The sentencing court may correct an illegal sentence at any time and may correct a sentence imposed in an illegal manner within the time provided herein for the reduction of sentence."
[3]  Correcting this sentence would not be that difficult. N.D.C.C. § 12-54.1-01 states:

Offenders sentenced to the penitentiary or state farm shall be eligible to earn good conduct sentence reductions. Whenever two or more sentences have been imposed upon an offender, the aggregate of the several sentences shall be the basis for determining the rate of reduction. Sentences may be reduced at the following rates:
....
5. Ten days per month on a sentence of ten years or more.
N.D.C.C. § 12-54.1-01 was amended in 1991 to state:
Except as provided under section 12.1-32-09.1, offenders sentenced to the penitentiary or any of its affiliated facilities are eligible to earn sentence reductions based upon performance criteria established through penitentiary rules. Performance criteria includes participation in court-ordered or staff-recommended treatment and education programs and good work performance. While incarcerated in the penitentiary or any of its affiliated facilities, an inmate may earn five days good time per month except for any sentence where the incarceration time is six months or less.
Since Ostafin's crime was committed before 1991 and the amendment of N.D.C.C. § 12-54.1-01, the applicable good time would be computed at the rate of ten days per month.
[1]  Because Trieb rejected the opportunity to withdraw his guilty plea, the trial court was correct when it advised Trieb that it could impose any sentence, up to and including the maximum for the offense Trieb had committed. As it happened, the trial court imposed a new sentence that closely approximated the intent of the original, provided that Trieb does not lose any of the good time it is assumed he will be able to earn. While at one point in Trieb III this court said, "[a]fter Trieb declined to withdraw his guilty plea, the resentencing left him with the benefit of his plea bargain," Trieb III, 533 N.W.2d at 681, such a disposition clearly was not necessary to sustain the legality of the sentence imposed. See Christopher Vaeth, Annotation, Guilty Plea as Affected by Fact That Sentence Contemplated by Plea Bargain Is Subsequently Determined to Be Illegal or Unauthorized, 87 A.L.R.4th 384, 397 (providing a list of cases that have held a defendant's plea of guilty can serve as the basis for the imposition of a lawful sentence when the defendant declines an opportunity to withdraw the plea of guilty after a determination that the agreed-upon sentence cannot be lawfully imposed).
