
734 N.E.2d 188 (2000)
315 Ill. App.3d 478
248 Ill.Dec. 480
The PEOPLE of the State of Illinois, Plaintiff-Appellee,
v.
Martin Patrick MYRIECKES, Defendant-Appellant.
Nos. 3-99-0497 to 3-99-0502.
Appellate Court of Illinois, Third District.
August 2, 2000.
Rehearing Denied August 24, 2000.
*190 Kerry J. Sluis (Court-appointed) (argued), Office of the State Appellate Defender, Ottawa, for Martin Patrick Myrieckes.
John X. Breslin, Deputy Director, State's Attorneys Appellate Prosecutor, Ottawa, Kevin W. Lyons, State's Attorney, Peoria, John Wood (argued), State's Attorneys Appellate Prosecutor, Ottawa, for the People.
Justice HOMER delivered the opinion of the court:
Defendant pled guilty to three counts of predatory criminal sexual assault of a child (720 ILCS 5/12-14.1(a)(1) (West 1996)) and three counts of aggravated criminal sexual abuse (720 ILCS 5/12-16(d) (West 1992)). He was sentenced to an aggregate of 80 years in prison. Defendant appeals arguing that he was sentenced in excess of the maximum term authorized by section 5-8-4(c)(2) of the Unified Code of Corrections (730 ILCS 5/5-8-4(c)(2) (West 1996)). Defendant also maintains that he was improperly sentenced based on the trial judge's mistaken belief that defendant was eligible for an extended-term sentence. Finally, defendant complains that one count of predatory criminal sexual assault of a child should be reversed because the indictment was defective. After our careful review, we affirm defendant's convictions but remand for resentencing.

FACTS
Defendant was charged with six counts of child pornography (720 ILCS 5/11-20.1(a)(1) (West 1996)), six counts of aggravated criminal sexual abuse (720 ILCS 5/12-16 (West 1992)), three counts of predatory criminal sexual assault of a child (720 ILCS 5/12-14.1(a)(1) (West 1996)), and two counts of aggravated criminal sexual assault (720 ILCS 5/12-14(b)(1) (West 1992) and 720 ILCS 5/12-14(b)(i) (West 1996)). The same basic pattern of abuse occurred with each of the young male victims involved. Defendant met the victims at a community development center as well as through the Roosevelt School after-school program. The boys were persuaded to come to defendant's home. They would then pose for videos, first in costume and then in the nude. Acts of sexual penetration *191 later occurred with three of the victims.
Defendant pled guilty to three counts of predatory criminal sexual assault of a child (720 ILCS 5/12-14.1(a)(1) (West 1996)) and three counts of aggravated criminal sexual abuse (720 ILCS 5/12-16(d) (West 1992)) in exchange for dismissal of the remaining charges and a promise from the State not to file any new charges based on information it had as of the date of the plea. At the plea hearing, the trial judge instructed defendant as to the potential sentencing range on each charge, as follows: (1) the charges of aggravated criminal sexual abuse were Class 2 felonies carrying a sentencing range of 3 to 7 years each with the possibility of an extended-term sentence (maximum 14 years each) if the victim was "12 years or under" at the time of the offense; and (2) the charges of predatory criminal sexual assault of a child were Class X felonies carrying a sentencing range of 6 to 30 years each with the possibility of an extended-term sentence (maximum 60 years each) if the complainant was "12 years or under" at the time of the offense. The trial judge also advised defendant that he could be given consecutive sentences if the court found it necessary to protect the public and that the maximum sentence defendant could receive would be 120 years.
The trial judge found that there was a factual basis for defendant's plea of guilty on each charge. The guilty plea was accepted, a presentence investigation was ordered, and a sentencing hearing was scheduled.
At the sentencing hearing, the court considered the presentence investigation report, which showed that defendant was 53 years old. Defendant had a 1978 conviction for child pornography and two 1995 traffic convictions. The State presented a 12-minute video compiled from four of the 61 video tapes found at defendant's apartment. The video showed defendant engaged in the charged conduct. Defendant made a statement to the court expressing his remorse and a desire to terminate his own life.
The trial court found that there were no statutory mitigating factors present. In addition, the court noted factors in aggravation, including defendant's criminal history, defendant's use of his position of trust in the community to commit his crimes, and the necessity of deterring others. The trial judge imposed consecutive sentences of 30, 30, and 20 years for the predatory criminal sexual abuse of a child charges and concurrent terms of seven years each for the aggravated criminal sexual assault charges.
Defendant filed a motion to withdraw his plea and a motion to reconsider his sentence. In the motion to withdraw, defendant alleged that his plea was not knowing and voluntary because, sleep deprived and suffering from stress and anxiety at the time, he was unable to understand his rights. Defendant also alleged that he had a bona fide defense to some of the charges. In his motion to reconsider, defendant argued the sentence was excessive and was cruel and unusual punishment in that it essentially amounted to a life term. Both motions were denied; however, the matter was remanded on appeal because the Rule 604(d) (134 Ill.2d R. 604(d)) certificate filed by trial counsel was insufficient.
Second amended motions to withdraw plea and to reconsider sentence were filed mirroring the allegations in the previously dismissed motions. This time, the Rule 604(d) certificate was adequate. Both motions were again denied. Defendant now appeals.

ANALYSIS

I. Aggregate of Consecutive Sentences
Defendant argues that the aggregate sentence of 80 years incarceration exceeds the maximum sentence authorized by law. Section 5-8-4(c)(2) of the Unified Code of Corrections provides, in relevant part, that "the aggregate of consecutive *192 sentences shall not exceed the sum of the maximum terms authorized under Section 5-8-2 for the 2 most serious felonies involved." 730 ILCS 5/5-8-4(c)(2) (West 1996). Section 5-8-2 provides, in relevant part, as follows:
"(a) A judge shall not sentence an offender to a term of imprisonment in excess of the maximum sentence authorized by Section 5-8-1 for the class of the most serious offense of which the offender was convicted unless the factors in aggravation set forth in paragraph (b) of Section 5-5-3.2 were found to be present. Where the judge finds that such factors were present, he may sentence an offender to the following:
* * *
(2) for a Class X felony, a term shall be not less than 30 years and not more than 60 years." 730 ILCS 5/5-8-2 (West 1996).
Defendant notes that the plain language of section 5-8-2 provides for an extended-term sentence of between 30 and 60 years only if section 5-5-3.2(b) factors in aggravation are present. Consequently, as no section 5-5-3.2(b) factors are present in the instant case, defendant contends that the plain language of section 5-8-2 authorizes only the nonextended term of 30 years provided for under section 5-8-1. Therefore, the sum of the maximum terms authorized for the two most serious felonies involved in this case, according to defendant, is only 60 years. The 80-year aggregate sentence would exceed this limit.
Defendant argues in the alternative that section 5-8-4(c)(2) is ambiguous. Defendant suggests that the language in section 5-8-4(c)(2) referring to "the maximum terms authorized" could refer either to the general sentencing ranges for the relevant class of felony or could refer to the sentencing range applicable to the defendant based on the specific facts of the case. Because any ambiguity in a criminal statute is to be construed in favor of the criminal defendant (People v. Daniels, 172 Ill.2d 154, 163, 216 Ill.Dec. 664, 665 N.E.2d 1221, 1225 (1996)), defendant contends that we must read the language as only permitting a 60-year aggregate term in this case.
A similar argument was rejected by the appellate court in People v. Woods, 131 Ill.App.3d 51, 86 Ill.Dec. 375, 475 N.E.2d 589 (1985). Defendant argues that we should reach a contrary result as (1) Woods is not binding authority in the third district; (2) Woods was decided 15 years ago; and (3) Woods is the only published case in Illinois to have considered this issue. We believe, however, that the first district correctly construed section 5-8-4(c)(2). The plain language of section 5-8-4(c)(2) refers to the "maximum terms authorized" by section 5-8-2, not to the maximum terms for which a particular defendant is eligible. (Emphasis added.) See 730 ILCS 5/5-8-4(c)(2) (West 1996).
Furthermore, our supreme court, albeit in dicta, has interpreted section 5-8-4(c)(2) consistently with the first district's construction in Woods. In People v. Tucker, 167 Ill.2d 431, 437, 212 Ill.Dec. 664, 657 N.E.2d 1009, 1012 (1995), our supreme court stated:
"We note that section 5-8-4(c)(2) refers to the aggregate of the maximum extended terms authorized for the two most serious felonies involved. [Citation.] For example, where a defendant is convicted of a Class X felony, the maximum extended-term is 60 years. [Citation] Thus, a defendant convicted of a number of Class X felonies may be sentenced to consecutive terms of imprisonment not to exceed a total of 120 years." (Emphasis in original.)
Consequently, we hold that the maximum aggregate of consecutive terms was 120, not 60 years. The 80-year aggregate sentence which defendant received is within this range.

II. Excessive Sentence
Defendant also argues that he received an excessive sentence based on the trial *193 court's mistaken belief that he was eligible for an extended-term sentence. At the plea hearing, the trial judge admonished defendant that he would be eligible for an extended-term sentence if the victim in any of the cases was 12 years old or younger. This admonishment, however, was incorrect because the statute providing for enhanced sentencing based on the youth of the victim permits extended-term sentencing if the victim is "a person under 12 years of age at the time of the offense" (emphasis added) (730 ILCS 5/5-5-3.2(b)(4)(i) (West 1996)). Furthermore, the parties agree, and the record confirms, that while two of the victims were 12 years of age, none was under 12 years of age on the dates alleged in the indictments.
Because the trial judge mistakenly believed defendant was extended-term eligible, defendant argues, defendant received an excessive sentence even though the sentences given were within the nonextended-term range. A trial court's misapprehension as to extended-term sentencing eligibility necessitates a new sentencing hearing when it appears that the trial court's misapprehension arguably influenced the sentencing decision. People v. Hurley, 277 Ill.App.3d 684, 687, 214 Ill. Dec. 606, 661 N.E.2d 460, 462 (1996). Even though this court cannot be certain that the judge's mistaken belief entered into the sentencing calculation, defendant argues, we should remand for resentencing because we cannot be certain that this improper factor did not affect the sentence. See People v. Embry, 179 Ill. App.3d 1059, 1060-61, 128 Ill.Dec. 873, 535 N.E.2d 87, 88 (1989) (remanded for resentencing because appellate court unable to determine the weight given to improperly considered factors).
The defendant did not object to the court's statement at the time of his plea or at sentencing, and the defendant did not include the issue in a post-sentencing motion. Objections regarding sentences not brought to the trial court's attention are deemed to be waived. People v. Brown, 242 Ill.App.3d 465, 182 Ill.Dec. 907, 610 N.E.2d 776 (1993). Furthermore, a defendant must file a written post-sentencing motion in the trial court to preserve a sentencing issue for appellate review. People v. Reed, 177 Ill.2d 389, 226 Ill.Dec. 801, 686 N.E.2d 584 (1997). Therefore, the State argues the issue is waived.
However, based upon our review of the record in this case, we find that a substantial right of defendant has been affected. See People v. Lindsay, 247 Ill.App.3d 518, 527, 187 Ill.Dec. 181, 617 N.E.2d 389, 395 (1993) (trial court finding that defendant was eligible for an extended term affected substantial rights, as it enabled court to impose a sentence twice the normal maximum). Therefore, we will review the alleged error under the plain error doctrine. 134 Ill.2d R. 615(a).
It is assumed that a trial judge considers only competent evidence in making his sentencing determination, and this assumption is overcome only if the record affirmatively demonstrates the contrary. People v. Kolzow, 301 Ill.App.3d 1, 8, 234 Ill.Dec. 563, 703 N.E.2d 424, 430 (1998). In considering whether a mistaken belief influenced the trial judge's sentencing decision, a reviewing court looks to whether the trial judge's comments show that the trial judge relied on the mistaken belief or used the mistaken belief as a reference point in fashioning the sentence. People v. Hill, 294 Ill.App.3d 962, 970, 229 Ill.Dec. 324, 691 N.E.2d 797, 803 (1998).
As previously noted, the trial judge misstated the law with respect to extended-term sentencing eligibility during the plea hearing. Furthermore, the record shows that defendant was not eligible for an extended-term sentence based upon the ages of the victims. At the sentencing hearing, the judge did not indicate the sentencing range or whether he believed defendant was eligible for an extended-term. However, it appears from the transcript of the sentencing hearing that the *194 parties so believed. The State put on evidence that one of the undisclosed victims appearing on the videotape claimed to be 11 years of age at the time. In aggravation, the State commented that for a victim "under 12 years of age at the time of the offense * * * that an extended-term is available." Defense counsel stated in his argument as to sentencing alternatives that he hoped for defendant's sake that "a sentence could be fashioned within the maximum that is available without getting into extended sentences."
Because the record suggests that the trial court erroneously believed that defendant was eligible for extended-term sentencing in this case, based upon the age of one or more of the victims, we vacate the sentence imposed and remand for resentencing.

III. Predatory Criminal Sexual Assault of R.H.
In a supplemental appeal, defendant asks us to reverse his conviction for the predatory criminal sexual assault of R.H. because R.H. was 13 years old during the time frame alleged in the indictment. One element of the crime of predatory criminal sexual assault of a child is that the victim is under the age of 13. Defendant argues that, because R.H. was 13 years old at the time of the conduct alleged in the indictment, the indictment failed to charge an offense and thus was void. Though defendant did not raise this issue in his post-plea motions, defendant asserts that the issue is not waived because in the absence of allegations charging a violation of the criminal law, the trial court has no jurisdiction to convict and defendant cannot by waiver or consent confer such jurisdiction or authority on the court. People v. Latham, 13 Ill.App.3d 371, 373, 299 N.E.2d 808, 809 (1973). Furthermore, even if the issue were waived, defendant notes, a conviction based upon a defective instrument constitutes plain error. 134 Ill.2d R. 615(a).
The State argues that the indictment is not defective. The indictment alleges that R.H. was under 13 years old, that the defendant was 17 years of age or older and that the defendant knowingly committed an act of sexual penetration on R.H. The State correctly notes that the indictment thus alleges the elements of the offense of predatory criminal sexual assault of a child. See 720 ILCS 5/12-14.1(a)(1) (West 1996).
The purpose of a legal challenge to an indictment for failure to state an offense is to challenge the sufficiency of the allegation in the charging instrument, not the sufficiency of the evidence; a defendant may not challenge an indictment on the grounds that it is not supported by adequate evidence. People v. Finley, 209 Ill.App.3d 968, 974, 154 Ill.Dec. 412, 568 N.E.2d 412, 415-16 (1991). Consequently, whether or not there was adequate evidence that R.H. was under 13 is irrelevant to a challenge to the sufficiency of the indictment.
A voluntary guilty plea waives all nonjurisdictional errors or defects, including constitutional errors. People v. Scott, 277 Ill.App.3d 579, 214 Ill.Dec. 110, 660 N.E.2d 555, 557 (1996). Furthermore, it is not unlawful for the State and a defendant to bargain for a plea of guilty to even a nonexistent crime if the defendant receives a benefit. People v. Johnson, 200 Ill.App.3d 1018, 1023, 146 Ill.Dec. 644, 558 N.E.2d 607, 610 (1990). Having secured dismissal of 11 additional pending charges and a promise from the State not to pursue additional charges, defendant has received a benefit in exchange for his guilty plea. Consequently, defendant is not in a position to now challenge the sufficiency of the evidence in support of his conviction.

CONCLUSION
For the foregoing reasons, the judgment of the circuit court of Peoria County is affirmed in part and reversed in part.
*195 Affirmed in part and reversed in part; cause remanded.
LYTTON and KOEHLER, JJ., concurred.
