
267 Kan. 543 (1999)
987 P.2d 1055
STATE OF KANSAS Appellee,
v.
ANTONIO PEREZ, JR., Appellant.
v.
STATE OF KANSAS, CHARLES E. SIMMONS, SECRETARY KANSAS DEPARTMENT OF CORRECTIONS, Appellee.
No. 80,352.
Supreme Court of Kansas.
Opinion filed July 9, 1999.
Debra J. Wilson, assistant appellate defender, argued the cause, and Jessica R. Kunen, chief appellate defender, was with her on the briefs for appellant.
Lois K. Malin, assistant county attorney, argued the cause, and John P. Wheeler, county attorney, and Carla J. Stovall, attorney general, were with her on the brief for appellee.
The opinion of the court was delivered by
SIX, J.:
These two consolidated cases concern adult prosecution and sentencing of a juvenile. Antonio Perez, Jr., a 14-year-old, was prosecuted and sentenced as an adult. Perez was charged with *544 rape, K.S.A. 21-3502(a)(1)(C), and bargained for a plea to the reduced charge of attempted rape, K.S.A. 21-3301(a). We granted Perez' petition for review from the denial of a K.S.A. 1998 Supp. 60-1501 habeas corpus petition in the Court of Appeals.
In a separate appeal (No. 80,352), Perez raised the validity of his authorization as an adult by challenging the admission of his confessions to a social worker and police officer. We consolidated the two cases so that all of Perez' claims may be resolved.
Perez' prosecution as an adult was proper; however, because he pled to and was convicted of the lesser included offense of attempted rape, a severity level 4 nonperson felony, he could not be sentenced as an adult. We vacate Perez' sentence and remand to the district court to sentence him as a juvenile offender.

FACTS
By the age of 14, Perez had been involved in several juvenile programs and was deemed a child in need of care. He was under the supervision of Jayne Hodges of Kansas Social and Rehabilitation Services. On June 28, 1995, Hodges received a call from the Garden City Police informing her that Perez was in custody. Hodges went to the police station. She had a short conversation with someone at the station desk. She understood Perez was being held on a charge involving a sex crime.
Hodges spoke to Perez in a holding cell. Perez told her that he had been at a friend's house drinking with some girls. According to Perez, one of the girls, 14-year-old S.G., was flirting with him. Later, his friend "Rocky" went into a bedroom with S.G. Perez said he was not sure what took place in the bedroom. When Rocky came out, he told Perez, "It's my girl, it's your turn." Perez then went into the bedroom. Hodges asked him if he had sex with the girl. Perez said yes.
Before leaving the police station, Hodges had another conversation with the desk officer. She does not remember whether she related Perez' incriminating statements but agreed it was possible. Hodges reported her conversation with Perez to her supervisor who then contacted the county attorney.
*545 While in custody, Perez also spoke to Detective Willie Relph. Relph was an expert on youth gangs and had prior contacts with Perez. Perez associated with a gang called the "Aztecs." He signed a waiver of his Miranda rights before speaking to Relph. He told Relph that he, Rocky, and "Little Loco" went to S.G.'s house. S.G. was Rocky's girlfriend. All four were sipping hard liquor, but S.G. was drinking considerably more than the others. At one point, S.G. became so intoxicated she began hugging and kissing Perez, mistakenly thinking it was Rocky. Rocky and S.G. then went into a bedroom and shut the door. Some time later, Perez walked into the room while Rocky and S.G. were engaged in sexual intercourse. Rocky then got up and told Perez to go ahead and have sex with S.G. Perez admitted having sex with S.G. He also told Relph that at some point he moved a dresser in front of the door so that the younger kids in the living room would not walk in and see what was happening.
S.G.'s mother testified she came home to find S.G. on the bedroom floor. S.G. was not moving. Her shorts were off, and her underwear was lying next to her, partially ripped. S.G.'s mother carried her into the living room and called the police. An ambulance took S.G. to the hospital.
The examining physician testified S.G.'s blood alcohol level was.249. S.G. had several bruises on her body, including her neck, left breast, and thigh. The physician could not detect whether the bruises were related to the alleged rape. There were no signs of trauma to the vagina, cervix, or rectum.
Perez was charged with the juvenile offense of rape but was later authorized for prosecution as an adult and re-charged with rape under K.S.A. 21-3502(a)(1)(C). He immediately appealed the authorization, but that appeal was dismissed by the district court for lack of jurisdiction. (K.S.A. 1998 Supp. 38-1681[a][1] directs that appeals from authorization for prosecution as an adult must be taken after conviction.) Perez then entered into a plea agreement. The State agreed to file an amended petition charging attempted rape. Perez pled guilty to the lesser charge and received a 38-month sentence. He filed a habeas corpus action with the Court *546 of Appeals contending his sentence was illegal and also appealed the district court's order authorizing his prosecution as an adult.

DISCUSSION
Perez now claims he is being held unlawfully because under K.S.A. 38-1636(i) he was convicted of a "lesser included offense" and, thus, could not be sentenced as an adult. The Court of Appeals stayed Perez' habeas petition until the resolution of Melton v. State, 25 Kan. App.2d 641, 967 P.2d 356 (1998), also involving K.S.A. 38-1636(i). After the decision in Melton, Perez's habeas petition was denied. We discuss Melton later in the opinion.
We have reviewed the record and find the district court did not err in authorizing Perez' prosecution as an adult. The standard for evaluating whether the decision to authorize adult prosecution was proper is whether the decision was supported by substantial evidence. State v. Tran, 252 Kan. 494, Syl. ¶ 8, 847 P.2d 680 (1993). We find adequate support for adult prosecution in the record. However, the result we reach on the sentencing issue negates the need to analyze the adult prosecution issue. Perez seeks the same relief, vacation of his sentence, in both cases.

Perez' Sentence
We consider the sentencing issue which controls the disposition of both cases. Perez contends his sentence is illegal because: (1) he was convicted of a lesser included offense (attempted rape); thus, under K.S.A. 38-1636(i), the district court should have treated him as a juvenile offender and punished him under the juvenile statute, K.S.A. 1994 Supp. 38-1663; and (2) his conviction for attempted rape is a severity level 4 person felony, and K.S.A. 38-1636(f) (2) does not authorize prosecution as an adult for such an offense.
The interpretation of statutes is a question of law. State v. Theis, 262 Kan. 4, 7, 936 P.2d 710 (1997). The parties agree that the standard of review to be applied here is de novo.

K.S.A. 38-1636(i)
The version of K.S.A. 38-1636(i) in effect at the time of Perez' offense stated:

*547 "If the respondent is prosecuted as an adult under subsection (f)(1) or (f)(2) and convicted of a lesser included offense, the respondent shall be a juvenile offender and receive an authorized disposition pursuant to K.S.A. 38-1663, and amendments thereto." (Emphasis added.)
The Court of Appeals dismissed Perez' habeas petition after filing Melton, 25 Kan. App.2d 641. In Melton, a 15-year-old was charged with felony murder. The State sought and obtained authorization to prosecute Melton as an adult. After negotiations, Melton entered a no contest plea to second-degree murder. Melton later filed a K.S.A. 60-1507 motion. He argued his sentence was illegal because he was convicted of a lesser included offense, and under K.S.A. 38-1636(i), he should have been sentenced under the juvenile code.
The Court of Appeals reasoned:
"K.S.A. 38-1636 permits a juvenile to be prosecuted as an adult under certain circumstances. Interestingly, K.S.A. 38-1636(i) states that if a juvenile is prosecuted as an adult under subsections (f)(1) or (f)(2) but is convicted of a lesser included offense, the juvenile shall be a juvenile offender and sentenced pursuant to the juvenile code.
"Instead, Melton was charged with second-degree murder pursuant to an amended petition, which relates back to the original petition. K.S.A. 60-215(c). Accordingly, second-degree murder is the only crime for which Melton was charged. There is no lesser included offense and K.S.A. 38-1636(i) simply is inapplicable." (Emphasis added.) 25 Kan. App.2d at 642.
Perez argues Melton does not apply to him. He reasons that Melton's plea to second-degree murder, a level 2 felony, distinguishes that case from his.
The premise of Melton is that when a defendant is charged in an amended complaint, the amendment relates back to the original complaint under K.S.A. 60-215(c). Thus, the defendant who enters a plea to an amended complaint is convicted with the crime charged, not a lesser included offense of the crime charged. However, K.S.A. 60-215(c) does not apply to criminal proceedings. K.S.A. 60-215(c) is part of the code of civil procedure. Its application has been twice rejected in the context of a notice of appeal in a criminal case. See State v. Medina, 256 Kan. 695, 701, 887 P.2d 105 (1994); State v. Grant, 19 Kan. App.2d 686, 688, 691, *548 875 P.2d 986, rev. denied 255 Kan. 1005 (1994) (notice of appeal in criminal case not considered a "pleading" within the meaning of K.S.A. 60-215[c]).
K.S.A. 1998 Supp. 22-3201(e) speaks to amendments of criminal complaints:
"The court may permit a complaint or information to be amended at any time before verdict or finding if no additional or different crime is charged and if substantial rights of the defendant are not prejudiced."
We disapprove of Melton's use of 60-215(c) in the context of a criminal case.
K.S.A. 21-3107(2) defines lesser included crimes. Attempted rape is a lesser included offense of rape. See K.S.A. 21-3107(2)(c) (an attempt to commit the crime charged is a lesser included crime). Because Perez was originally charged with rape but ultimately convicted of attempted rape, Perez was convicted of a lesser included offense. The legislature has directed that juveniles authorized for prosecution as adults who are convicted of lesser included offenses "shall" be sentenced as juveniles. The result is that Perez' adult sentence is illegal by operation of K.S.A. 38-1636(i).
The State focuses on the contractual nature of a plea bargain. According to the State, Perez as a "juvenile/adult" deserves all the due process owing to an "adult/adult." Arranging a plea agreement is one of those adult rights. A plea agreement is akin to a contract. See State v. Wills, 244 Kan. 62, 68-69, 765 P.2d 1114 (1988) (applying contract law to ambiguous plea agreement). Both parties to the agreement are bound by its terms. We have consistently forced the State to abide by its agreements with defendants. See e.g., State v. Ratley, 253 Kan. 394, Syl. ¶ 5, 855 P.2d 943 (1993). Perez agreed to enter a plea of guilty to attempted rape, knowing he would be convicted and sentenced as an adult. We find a degree of logic in the State's argument. However, the State's "rights as an adult" argument is trumped by the directory language of K.S.A. 38-1636(i).

K.S.A. 38-1636(f)(2)
Prosecution as an adult is not authorized for a 14-year-old charged with a severity level 4 person felony under K.S.A. 38-1636(f)(2). K.S.A. 38-1636(f)(2) states:

*549 "(f) The court may authorize prosecution as an adult upon completion of the hearing if the court finds that the respondent was: ...
"(2) 14 or 15 years of age at the time of the alleged commission of the offense, if the offense is an off-grid felony, a nondrug severity level 1, 2 or 3 felony or a drug level 1 or 2 felony, and that there is substantial evidence that the respondent should be prosecuted as an adult for the offense with which the respondent is charged." (Emphasis added.)
The sentencing issue was not raised in the district court; however, we may correct an illegal sentence at any time. K.S.A. 22-3504(1).
K.S.A. 1994 Supp. 38-1663 does not authorize a district court to sentence a juvenile offender to the Department of Corrections. Perez, by entering a plea to attempted rape, a severity level 4 nonperson felony, should be sentenced as a juvenile offender. The habeas relief Perez seeks in his original action filed in the Court of Appeals is merged in our disposition of his direct appeal. The facts here are unique and because of the recent amendments to K.S.A. 38-1636, may present a case of last impression. K.S.A. 1998 Supp. 38-1636(i) provides:
"If the respondent is prosecuted as an adult under subsection (a)(2) and is not convicted in adult court of an offense listed in subsection (a)(2) but is convicted or adjudicated of a lesser included offense, the respondent shall be a juvenile offender and receive a sentence pursuant to K.S.A. 38-1663, and amendments thereto." (Emphasis added.)
The offenses listed in K.S.A. 1998 Supp. 38-1636(a)(2) have been expanded to include nondrug severity levels 1 through 6 felonies.
The sentence imposed is vacated. The case is remanded. We were informed at oral argument that Perez is on postrelease in Garden City. Perez is to be sentenced as a juvenile offender under the versions of K.S.A. 1994 Supp. 38-1663 in effect at the time Perez committed the crime.
