*640The opinion of the court was delivered by
Abbott, J.:This is a sentencing case arising out of the period of transition from statutory indeterminate sentencing to sentencing under the Kansas Sentencing Guidelines Act (KSGA), K.S.A. 1993 Supp. 21-4701 et seq. The KSGA took effect July 1, 1993. We concentrate on the rules governing offenders who committed crimes before July 1, 1993, but were not sentenced until after July 1, 1993, although the same rules would apply to persons sentenced before July 1, 1993, if the statutory elements of the crime or crimes they committed changed on or before July 1, 1993.
The defendant, John E. Fierro, was sentenced on July 9, 1993, for offenses he committed over a three-year period from 1989 to 1992. He pleaded nolo contendere to six counts of attempted indecent liberties with a child in violation of K.S.A. 1992 Supp. 21-3503 and K.S.A. 1992 Supp. 21-3301, class D felonies. The district court at sentencing: (1) denied probation and assignment to community corrections and imposed 3- to 10-year sentences to be served concurrently; (2) computed Fierro’s sentence under the KSGA to be 32 months (grid block 5-1) on four counts and 18 months (grid block 6-1) on the remaining two counts (see K.S.A. 1993 Supp. 21-4704); and (3) did not state whether and, if so, how the guidelines sentence would be applied to Fierro’s benefit in the future.
Our jurisdiction is under K.S.A. 20-3018(c) (transfer from the Court of Appeals on our own motion).
FACTS
Fierro entered a plea of nolo contendere to an amended complaint charging him with six counts of attempted indecent liberties with a child. The district court accepted his plea and convicted him as charged on March 29, 1993. He appeared for sentencing on July 9, 1993.
Fierro, the State, and the district court agreed that Fierro’s sentence should be computed both under the pre-guidelines statutes and under the KSGA. See K.S.A. 1993 Supp. 21-4724(f). *641They disagreed on what the appropriate sentence would be under both schemes and on which scheme would control his sentence.
The district court believed the pre-guidelines sentence would control but also computed the guidelines sentence:
“As I understand it, what is going to control his sentence is the original sentencing and I think I've covered that. The only thing that die guidelines require was that I compute what I considered to be ... his sentence under the guidelines as a guide to die corrections people and the parole board in die future.”
In determining the pre-guidelines sentence, the trial court found that the maximum sentence should be imposed under the statute in existence when the crimes were committed, which was 3 to 10 years’ imprisonment for each count. See K.S.A. 21-4501(d)(1). The six terms were made concurrent.
In calculating what Fierro’s guidelines sentences would be, the trial court applied K.S.A. 1993 Supp. 21-3504, aggravated indecent liberties, and set the sentences at 32 months on counts 2, 3, 4, and 6 and 18 months on counts 1 and 5.
THE ISSUES
We consider whether the district court: (1) was required by K.S.A. 1993 Supp. 21-4724(f) or by equal protection principles to apply the guidelines retroactively to Fierro and (2) correctly determined Fierro’s sentence. Three additional issues also require our review: (1) a preliminary challenge by the State to Fierro’s standing; (2) the preservation of questions for appeal; and (3) an assertion by Fierro that the district court showed bias or prejudice towards him at sentencing.
Standing
The State contends that Fierro lacks standing to challenge the constitutionality of the KSGA, relying on the general rule that a party must have a sufficient interest in and have been aggrieved by a judgment in order to appeal. See Gigot v. Cities Service Oil Co., 241 Kan. 304, Syl. ¶ 1, 737 P.2d 18 (1987). The State attempts to use a statement from Fierro’s brief that he is not “disadvantaged by the application of the sentencing guidelines” as an admission he has no standing. The State’s argument is not well taken. The statement in Fierro’s brief is lifted from its context. *642Fierro alleges that he is disadvantaged by what he claims is unequal treatment by the guidelines’ retroactivity provision. Fierro wants the guidelines to control his sentence because they impose on him a shorter term under the district court’s calculation (32 months, maximum) than the statutory senténce he is presently serving (3 to 10 years) and, under his analysis, die guidelines mark him for presumptive probation. He has standing to bring his constitutional challenge.
Preservation of Constitutional Issues for Appeal
The State also claims that “[t]he trial court was not requested to rule on [the] issue. regarding the [KSGA] violating the due process, ex post facto, and equal protection clauses of the United States Constitution.’’ Thus, the State contends that we should not address these issues.
Contrary to the State’s assertion, Fierro raised his equal protection and ex post facto arguments in the proceedings below. Fierro’s counsel stated at the sentencing hearing that diere was a problem under equal protection principles with having the preguidelines statutes control Fierro’s sentence, rather than the guidelines. The district court agreed with Fierro but chose not to make a ruling on those grounds, saying it was not a problem that could be solved that day. The record indicates that the district court anticipated the issue being raised on appeal, and for that reason the court did not give die issue any further consideration. With respect to the ex post facto argument, Fierro’s counsel discussed this claim at length in his brief in opposition to the State’s successful motion to reconsider the sentence. We conclude that Fierro properly raised his equal protection and ex post facto arguments in the trial court.
As for Fierro’s due process argument, the State may be correct because we are unable to locate in the record where Fierro expressly objected to the guidelines or to his sentence on due process grounds. However, this omission is of no practical consequence because the only specific and independent due process argument that Fierro appears to make on appeal is virtually indistinguishable in substance from his equal protection argument. *643We have recognized that the analyses under the equal protection and due process clauses are almost identical. See Chiles v. State, 254 Kan. 888, Syl. ¶ 10, 869 P.2d 707, cert. denied 115 S. Ct. 149 (1994) (“The test in determining the constitutionality of a statute under due process or equal protection concepts weighs almost identical factors.”). We will review Fierro’s equal protection and ex post facto arguments.
DISCUSSION
The Equal Protection Challenge
There is uncertainty and disagreement between the parties about how the guidelines and pre-guidelines sentencing schemes apply to Fierro and others sentenced after July 1, 1993, for crimes committed before that date. The district court did not indicate whether, in its view, Fierro would be entitled to convert his statutory sentence to the guidelines sentence at some later date and, if so, how such conversion would occur. Cf. State v. Gonzales, 255 Kan. 243, 250, 874 P.2d 612 (1994) (conversion is mandatoiy for persons sentenced before July 1, 1993, if they qualify for retroactivity under K.S.A. 1993 Supp. 21-4724[b]).
This appeal involves statutory construction. The interpretation of a statute is a question of law. Our standard of review is unlimited. State v. Donlay, 253 Kan. 132, 133-34, 853 P.2d 680 (1993).
Fierro contends that K.S.A. 1993 Supp. 21-4724 excludes otherwise qualified offenders like him, who committed their crimes before July 1, 1993, but were sentenced after that date, from the benefits of retroactivity. He argues that he is therefore treated less favorably than similar offenders sentenced before July 1, 1993. The disparate treatment, he asserts, is not supported by a rational basis and thus violates the Equal Protection Clause of the 14th Amendment. Fierro’s constitutional challenge is one of first impression. It involves a different challenge to K.S.A. 1993 Supp. 21-4724 than the one we resolved in Chiles v. State, 254 Kan. at 901 (finding, in part, that the “more serious versus less serious offenses” classification for determining to whom retro-activity applies has a rational basis and thus passes equal protection challenge).
*644In Gonzales, 255 Kan. at 250-51, we held that conversion to a guidelines sentence is mandatory for persons who qualify for retroactivity under K.S.A. 1993 Supp. 21-4724(b). Subsection (b) applies, in pertinent part, to persons sentenced prior to July 1, 1993, “who committed crimes which would be classified in a presumptive nonimprisonment grid block on either sentencing grid, [or in a border box of the nondrug grid] ... , if sentenced pursuant to the Kansas sentencing guidelines act.” (Emphasis added.) K.S.A. 1993 Supp. 21-4724(b).
Fierro was sentenced on July 9, 1993, and therefore the district court applied K.S.A. 1993 Supp. 21-4724(f), which states:
“In the case of any person to whom the provisions of this section shall apply, who committed a crime prior to July 1, 1993, but was sentenced after July 1, 1993, the sentencing court shall impose a sentence as provided pursuant to law as the law existed prior to July 1, 1993, and shall compute the appropriate sentence had the person been sentenced pursuant to the Kansas sentencing guidelines.”
Under K.S.A. 1993 Supp. 21-4724(f), the district court concluded that Fierro’s controlling sentence was the pre-guidelines 3- to 10-year term. The district court also computed Fierro’s guidelines sentence, as subsection (f) requires, but gave no indication if or when the guidelines sentence might become relevant. The district court did not apply the guidelines retroactively to Fierro.
It is unclear whether and, if so, how Fierro would be able to convert his sentence to the guidelines sentence at some time in the future, assuming his pre-guidelines sentence initially controls under the district court’s order. The KSGA does not expressly provide Fierro such a right. The conversion procedure established in K.S.A. 1993 Supp. 21-4724 applies only to “persons who committed crimes and were sentenced prior to July 1, 1993.” K.S.A. 1993 Supp. 21-4724(c)(l) begins:
"Except as provided in subsection (f), the department of corrections shall conduct a review of all persons who committed crimes and were sentenced prior to July 1, 1993, and are imprisoned in the custody of the secretary of corrections as of that date.”
The “Except as provided in subsection (f)” language is confusing, since subsection (f) expressly applies to a completely different *645group of persons (“sentenced after July 1, 1993”) than those to whom subsection (c)(1) expressly applies (“sentenced prior to July 1, 1993”). We do not see how subsection (f) is an “exception” to (c)(1), since the two provisions seem exclusive of each other on their own terms. We reason that the legislature intended to cross-reference subsection (f) in subsection (c)(1) to highlight the fact that the two provisions apply to separate groups of offenders and that offenders who fall under subsection (f) were not entitled to (and would not necessarily need) the conversion procedure outlined in subsections (c) and (d).
The 1994 Kansas Sentencing Guidelines Desk Reference Manual, prepared by the Kansas Sentencing Commission, vaguely suggests that some otherwise eligible offenders (based on the 21-4724[b] “less serious offense” criteria) sentenced after July 1, 1993, may be able to receive the benefits of retroactivity. In discussing 21-4724(f), the manual states the following:
“For those offenders who committed crimes prior to July 1, 1993, but who were sentenced after that date, the court must impose a sentence pursuant to tire law in effect before July 1, 1993. However, the guidelines sentence must be computed as well as a means of determining whether the offender is thereby excluded from eligibility for retroactive application of the sentencing guidelines or not. The offender may challenge the compiled criminal histoiy prior to sentencing. The Department of Corrections may use this information to determine eligibility for retroactive application of the guidelines, or a court may take judicial notice of these documents in a subsequent hearing.” (Emphasis added.) 1994 Kansas Sentencing Guidelines Desk Reference Manual, p. 37.
If, as the Sentencing Commission suggests, the purpose of computing the guidelines sentence for persons sentenced after July 1, 1993, is to determine whether they are eligible for retroactivity (i.e., whether their guidelines sentence falls within the presumptive probation or border box grid blocks), then the natural implication is that offenders deemed eligible will receive the benefits of retroactivity. If a particular offender would not benefit from a retroactive application of the guidelines, but rather would be disadvantaged, then the offender s original pre-guidelines sentence would remain in effect. K.S.A. 1993 Supp. 21-4724(e) (“A person’s sentence shall not be increased in length through a conversion to one under sentencing guidelines.”); see State v. Nunn, *646244 Kan. 207, 219, 768 P.2d 268 (1989). The State makes a similar assertion about the application of K.S.A. 1993 Supp. 21-4724, alleging that for eligible offenders, “both sentences will be administered by the Department of Corrections [and] whichever sentence has the earliest release date is the one the Department of Corrections will abide by.” Thus, the State seems to agree with our assessment of the interplay between the pre- and post-guidelines sentencing schemes.
We believe that when including subsection (f) in K.S.A. 1993 Supp. 21-4724, the legislature was trying to avoid any potential ex post facto problems resulting in the event that the guidelines increased the penalty for a particular offender who committed a crime before the July 1, 1993, effective date, but who was not sentenced until after that date. See K.S.A. 1993 Supp. 21-4724(e). An ex post facto violation occurs when a new law is retroactively applied to events that occurred before its enactment and the new law disadvantages the offender affected by it. Miller v. Florida, 482 U.S. 423, 430, 96 L. Ed. 2d 351, 107 S. Ct. 2446 (1987). By inserting a blanket prohibition on adverse retroactivity for preJuly 1, 1993, offenders sentenced after the effective date, the legislature ensured that no such offender would receive a longer sentence because of the guidelines.
Would the granting of retroactivity to some qualified offenders who committed crimes before July 1, 1993, but not to other similar offenders who also committed crimes before July 1, 1993, with the distinction based on the date of sentencing, violate the equal protection rights of similar offenders sentenced after July 1, 1993? Fierro thinks so¡, and we agree.
As in Chiles, the applicable level of scrutiny in Fierro’s case for the challenged classification based on the date of sentencing is the rational basis test. See Chiles, 254 Kan. at 901. The challenged legislative classification will be upheld if it bears a rational relationship to a legitimate objective. 254 Kan. at 892. The State has not articulated either a rational basis or a legitimate objective for providing beneficial retroactivity to one offender whose sentencing took place, for example, on June 30, 1993, while denying retroactivity to an otherwise identical offender whose sentencing *647took place on July 2, 1993. The State’s argument concerning the rational basis test is not persuasive. The State attempts to justify why different offenders’ hearings are held at different times, rather than why one group is given retroactivity while the other group is not.
In Chiles, we held that the line drawn by the legislature in providing retroactivity to “less serious” offenders but not to “more serious” offenders was “rationally related to the purpose of reducing the prison population while protecting public safety.” 254 Kan. at 901. We can drink of no comparable purpose for drawing a line between less serious offenders sentenced before July 1, 1993, and less serious offenders sentenced after that date. Such a line is not rationally related to public safety concerns, since both groups of offenders are among those deemed less serious.
If K.S.A. 1993 Supp. 21-4724(f) denied retroactivity to persons sentenced after July 1, 1993, who would otherwise qualify for retroactivity under 21-4724(b), the statute would violate the Equal Protection Clause. We therefore construe the statute as providing offenders sentenced after July 1, 1993, who are otherwise qualified for retroactivity under 21-4724(b), the same opportunity for retroactivity as offenders sentenced before that date. This construction is derived from legislative intent as expressed in K.S.A. 1993 Supp. 21-4724.
“ ‘In determining legislative intent, courts are not limited to a mere consideration of the language used, but look to tire historical background of the enactment, the circumstances attending its passage, the purpose to be accomplished and the effect the statute may have under the various constructions suggested.’
“ . . When the interpretation of one section of an act according to the exact and literal import of its words would contravene the manifest purpose of the legislature, the entire act should be construed according to its spirit and reason, disregarding so far as may be necessary the literal import of words or phrases which conflict with the manifest purpose of the legislature.’ ” Gonzales, 255 Kan. at 249 (quoting Brown v. Keill, 224 Kan. 195, Syl. ¶¶ 3, 4, 580 P.2d 867 [1978]).
Under the guidelines classification computed by the district court, Fierro qualifies for retroactivity under K.S.A. 1993 Supp. 21-4724(b).
Fierro’s Guidelines Sentence
We now address Fierro’s challenge to the district court’s com*648putation of his guidelines sentence. The question is whether the district court correctly determined Fierro’s sentence under the KSGA. Fierro contends that the district court committed an ex post facto violation in determining his offense severity level. He also contends that his correct guidelines sentence calls for presumptive probation and that the district court failed to justify its departure from probation in announcing his guidelines sentence. The parties agree that Fierro’s criminal history category is “I” (no prior record).
In addition to the first-impression nature of the interplay between pre- and post-guidelines sentences, the case at bar also presents a general question of first impression concerning how a sentencing court should determine a guidelines sentence for a crime committed before July 1, 1993. Many of the substantive criminal statutes were substantially amended when the guidelines were enacted. Crimes that were previously defined in broad terms and classified as a general class of felony were broken down by the legislature into different crimes and were assigned different severity levels. Many of the variations that now give rise to different severity levels did not exist in the criminal laws prior to July 1, 1993. The indecent liberties and aggravated indecent liberties statutes at issue in Fierro’s case are but two examples. Similar problems have arisen with aggravated batteiy, see State v. Houdyshell, 20 Kan. App. 2d 90, 884 P.2d 437 (1994), and aggravated incest, see State v. Colston, 20 Kan. App. 2d 107, 883 P.2d 1231 (1994).
The problem is this: The substantive criminal statutes that defined crimes before July 1, 1993, did not contain “severity levels,” which are necessary to compute a guidelines sentence under the KSGA. Severity levels are found only in the substantive criminal statutes that took effect July 1, 1993. Had the legislature made no substantive changes to the criminal laws when enacting the guidelines, but simply converted the “class felony” system to a “severity level” system without touching the names, elements, and definitions of the substantive crimes, the perplexing problem now before us would not exist. However, the legislature made substantial changes to many substantive crimes. As a result, it is often *649difficult to determine the guidelines severity level of a pre-July 1, 1993, offense.
The reasoning of this appeal applies to all those crimes amended effective July 1, 1993, plus any crimes amended after a prisoner commenced serving a sentence, whether the amendment occurred before or after July 1, 1993. They are countless and involve a large number of prisoners.
Historically, and in this case, the fundamental rule is that a person convicted of a crime is given the sentence in effect when the crime was committed. See State v. Reed, 248 Kan. 792, 795, 811 P.2d 1163 (1991). That rule is codified in K.S.A. 1993 Supp. 21-4723 and K.S.A. 1993 Supp. 21-4724(f), which require the sentencing court to impose a sentence as provided pursuant to law as the law existed prior to July 1, 1993. The sentence imposed on Fierro was 3 to 10 years in prison. The conversion of that sentence is an act of grace on the part of the legislature, and so long as all persons similarly sentenced are treated the same there is no constitutional issue. In those cases where a crime is committed prior to July 1, 1993, and sentencing occurs after that date, although the trial court must impose a sentence according to the pre-July 1, 1993, law, K.S.A. 1993 Supp. 21-4724(f) also requires the trial judge to next compute what the sentence would be had the defendant been sentenced pursuant to the Kansas sentencing guidelines. Why is this provision in the statute? The issue before us is one of legislative intent. We believe the provision requiring calculation of the guidelines sentence by the trial court was added by the legislature to enable the trial court to resolve the guidelines issue while the facts were fresh and readily available to both the defendant and the.prosecutor and to prevent subsequent appeals to the trial court should the defendant or the prosecutor disagree with the Department of Corrections’ calculations on conversion.
In cases involving prisoners already serving sentences on July 1, 1993, the legislature provided that if a dispute arose as to conversion, that person could request a hearing in the trial court in which the person was originally sentenced (either direct review or as a K.S.A. 60-1507 motion) and have the dispute settled. That step is not necessary for those sentenced after July 1, 1993, be*650cause the legislature wisely provided for those issues to be disposed of at sentencing by having the trial court compute the sentencing guidelines sentence just as the Department of Corrections does for prisoners who were serving sentences on July 1, 1993.
The legislature clearly intended that the defendant’s sentence be modified by comparison with the sentencing guidelines as if the “crime” had been committed on or after July 1, 1993. In converting a sentence, the legislature intended that the Department of Corrections use records available to it to determine what the defendant did when the crime was committed and convert that crime to an analogous crime existing after July 1, 1993. This is reflected throughout the sentencing guidelines. See, for. example, K.S.A. 1993 Supp. 21-4707(b), (c)(1), and K.S.A. 1993 Supp. 21-4711(e).
The legislature also allows the Department of Corrections to compute criminal history based on its own records and the records of others, which in many cases are not part of the defendant’s court record. A defendant’s criminal history includes juvenile offenses and criminal convictions that have been expunged. This shows legislative intent that the true facts of an offense be used to determine what the defendant would be sentenced to if the crime had occurred after July 1, 1993. The conversion should be based on the facts and should not ignore what has been charged and either proven or admitted by the defendant, as in this case.
This case has significance in cases other than indecent liberties. It will apply to nearly all sex crimes involving minors as victims. It will also apply, for example, to aggravated arson, aggravated assault on a law enforcement officer, and aggravated battery on a law enforcement officer; to any offense where a firearm was used to commit a person felony; to drug crimes where solicitation, conspiracy, or attempt was not an element prior to 1993; and to many drug cases, based on the weight of the illegal substance.
Here, Fierro pleaded guilty to crimes involving victims whose ages are not in dispute. The legislature has expressed great concern for criminal acts directed at young children as demonstrated by the number of new crimes involving sexual acts committed on minors and by increasing penalties for these crimes.
*651We hold the legislature intended that the trial court compute the sentence under the sentencing guidelines by looking at actual conduct and by applying the actual acts committed to the comparable crime in effect after July 1, 1993.
It is important to remember the trial court at this stage is not dealing with guilt or innocence of a defendant. The defendant has been convicted and sentenced for the crime in effect when the defendant committed the crime. The issue before the court is whether the defendant will have a sentence reduction based on the severity level set by the legislature for crimes in effect on or after July 1, 1993.
The trial judge is not to impose a sentence under the sentencing guidelines. The trial judge has already imposed the sentence based on the statutes in effect when the crime was committed. All the trial judge is to do is compute the sentence that would have been imposed had the defendant been sentenced pursuant to the sentencing guidelines. K.S.A. 1993 Supp. 21-4724(f). The Department of Corrections will then require die defendant to serve the lesser of the two.
In summary we approve State v. Colston, 20 Kan. App. 2d 107, 883 P.2d 1231 (1994), and disapprove other Court of Appeals decisions to the contrary.
Bias or Prejudice at Sentencing
Fierro inteiprets some of the district court’s comments during the sentencing hearing as indicating a bias or prejudice against sex offenders and a “predisposition” in favor of imprisonment for pedophiles. He cites State v. Fisher, 249 Kan. 649, 652, 822 P.2d 602 (1991), in which we held that the district court’s comments indicated that it did not exercise any discretion in imposing a sentence of imprisonment on a narcotics offender, in violation of K.S.A. 21-4601. The sentencing record in the instant case does not support Fierro’s contention of bias. Nor does it support the contention that the district court was incapable of rendering a fair, objective, and impartial decision because of the nature of Fierro’s offenses.
CONCLUSION
Fierro qualifies for and is therefore entitled to retroactive ap*652plication of the KSGA. Consequently, his guidelines sentence controls to the extent that it benefits him. If it disadvantages him compared to his pre-guidelines sentence, then his pre-guidelines sentence must control. Therefore, both his pre-guidelines sentence and his guidelines sentence must be computed, separately, in order to effectively impose and administer Fierro’s sentence.The trial court properly computed Fierro’s pre-guidelines sentence and guidelines sentence.
Affirmed.