
577 N.W.2d 414 (1998)
STATE of Iowa, Appellee,
v.
Marvin Dewayne SISK, Appellant.
No. 97-744.
Supreme Court of Iowa.
April 22, 1998.
*415 Linda Del Gallo, State Appellate Defender, and James G. Tomka, Assistant State Appellate Defender, for appellant.
Thomas J. Miller, Attorney General, Sharon K. Hall, Assistant Attorney General, Thomas J. Ferguson, County Attorney, and Linda Jenson Hall, Assistant County Attorney, for appellee.
Considered by HARRIS, P.J., and LARSON, CARTER, LAVORATO, and ANDREASEN, JJ.
PER CURIAM.
Defendant appeals the judgment and sentence entered upon his convictions of delivery of a controlled substance as a second offender, and being an habitual offender, in violation of Iowa Code sections 124.401(1)(c), 124.411, and 902.8 (1995). He argues, among other things, that his forty-five-year sentence was not authorized pursuant to Iowa Code section 124.411(1) (providing that second or subsequent offenders of Iowa Code chapter 124, the Iowa Controlled Substances Act, may be punished by imprisonment for a period not to exceed three times the term otherwise authorized). We affirm.
Following a controlled drug buy involving the use of a police informant, the State charged defendant with delivery of a controlled substance as a second or subsequent offender, and with being an habitual offender. At trial the State presented evidence that on June 30, 1996, defendant sold cocaine to the informant. It further presented evidence that defendant had two prior convictions under chapter 124. The jury found defendant guilty of delivery of a controlled substance (a class "C" felony) as a second or subsequent offender.
Defendant stipulated that he had been convicted of delivery of a simulated controlled substance in February 1990 and convicted of possession with the intent to deliver cocaine in December 1993, both class "C" felony offenses. The court, therefore, found defendant was an habitual offender pursuant to section 902.8 (any person convicted of a class "C" or a class "D" felony, who has twice before been convicted of any felony), and was subject to a fifteen-year sentence under section 902.9(2).
The court then sentenced defendant to an indeterminate term of imprisonment not to exceed forty-five years by tripling the fifteen-year habitual offender sentence pursuant to the repeat offender statute, see section 124.411(1).
On appeal defendant argues the district court imposed an improper sentence pursuant to section 124.411(1) by tripling the fifteen-year sentence for habitual offenders under section 902.9(2). Section 124.411(1) provides:
Any person convicted of a second or subsequent offense under this chapter, may be punished by imprisonment for a period not to exceed three times the term otherwise authorized, or fined not more than three times the amount otherwise authorized, or *416 punished by both such imprisonment and fine.
(Emphasis added.)
Defendant contends that the term "otherwise authorized" in section 124.411(1) refers to the punishment authorized within chapter 124. The offense for which defendant was convicted, intent to deliver in violation of section 124.401(1)(c), is a class "C" felony punishable by a term of imprisonment not to exceed ten years pursuant to section 902.9(3). Therefore, defendant urges, the court was only authorized to sentence him to up to thirty years, triple the ten-year term.
The State notes that in addition to being convicted of delivery of a controlled substance, defendant was found to be an habitual offender based on his 1990 and 1993 convictions. Section 902.9(2) provides that an habitual offender shall be confined for no more than fifteen years. The State maintains that the district court properly sentenced defendant to a term of imprisonment that did not exceed three times the fifteen-year period authorized pursuant to sections 902.8 and 902.9(2).
Our review of challenges to the legality of a sentence is for errors at law. State v. Davis, 544 N.W.2d 453, 455 (Iowa 1996). We may correct an illegal sentence at any time. Id.
We have previously held that chapter 124 "clearly was not intended to stand completely on its own in sentencing." State v. Draper, 457 N.W.2d 600, 603 (Iowa 1990). In Draper, we examined whether sections 902.8 and 902.9(2) applied to a defendant who violated chapter 204 because that chapter has its own enhancement provision for second or subsequent violations. (Chapter 204 was transferred in its entirety to chapter 124 in the 1993 Code.) We found section 902.9 "dovetails" with section 204.401 by stating that it applies to the sentencing of "`any person convicted of a felony'" unless otherwise specified by another statute. Id. (quoting Iowa Code § 902.9 (1987)).
We also held in Draper that the penalty imposed under section 902.9(2) was not "separate" from chapter 204, rather it was the "`penalty imposed for violation of this division.'" Id. (quoting Iowa Code § 204.404). We explained that chapter 204 "simply borrows from chapter 902 in setting the length of the sentence for certain violations." Id.
In Draper we found that the defendant, who was convicted of three class "D" felonies pursuant to chapter 204 and found to be an habitual offender, was properly sentenced to fifteen years on each count pursuant to section 902.9(2) rather than to five years on each count pursuant to section 902.9(4) (providing sentence for class "D" felonies). However, because the defendant's prior convictions were not under chapter 204, we expressed "no opinion on the interplay between Iowa Code sections 204.411 and 902.9(2) in a situation where the terms of both might apply." Id. at 604 n. 3.
Here, where the terms of both sections 124.411 and 902.9(2) do apply, we find the district court properly sentenced defendant by looking first to chapter 902 to determine the penalty imposed for the violation of section 124.401(1)(c), a class "C" felony. Section 902.9(3) provides that a class "C" felon, not an habitual offender, shall be sentenced to no more than ten years. However, defendant was found to be an habitual offender; therefore, he must be sentenced pursuant to section 902.9(2) which provides that an habitual offender shall be sentenced to no more than fifteen years.
Next, because defendant's previous convictions were under chapter 124, the district court properly applied the repeat offender enhancement of section 124.411(1) which authorized it to punish defendant for a period not to exceed three times the period of fifteen years "otherwise authorized" by section 902.9(2).
We find that the district court properly sentenced defendant by imposing the penalty for an habitual offender under chapter 902 and then enhancing that sentence pursuant to section 124.411(1). We have considered and find no merit in the other issues defendant argues on appeal. Accordingly, we affirm defendant's convictions and sentence.
AFFIRMED.
