
733 N.E.2d 1235 (2000)
192 Ill.2d 36
248 Ill.Dec. 237
The PEOPLE of the State of Illinois, Appellant,
v.
Dennis PULLEN, Appellee.
No. 87542.
Supreme Court of Illinois.
July 6, 2000.
*1236 James E. Ryan, Attorney General, of Springfield, and Patrick J. Herrmann, State's Attorney, of Princeton (Joel D. Bertocchi, Solicitor General, William L. Browers and Lisa Anne Hoffman, Assistant Attorneys General, of Chicago, and Norbert J. Goetten, John X. Breslin and Terry A. Mertel, of the Office of the State's Attorneys Appellate Prosecutor, of Ottawa, of counsel), for the People.
Robert Agostinelli, Deputy Defender, and Carrie B. Marche and Peter A. Carusona, Assistant Defenders, of the Office of the State Appellate Defender, of Ottawa, for appellee.
Justice FREEMAN delivered the opinion of the court:
Defendant, Dennis Pullen, entered a negotiated plea in the circuit court of Bureau County. Claiming error in the sentencing, defendant filed an amended motion to withdraw the plea. The trial court denied defendant's motion. The appellate court reversed (304 Ill.App.3d 294, 237 Ill.Dec. 511, 709 N.E.2d 980), and the State appeals to this court. The single issue is whether the trial court erred in denying defendant's motion to withdraw his negotiated plea. Resolution of this issue requires us to determine the maximum aggregate sentence when consecutive sentences are imposed on a defendant who has committed Class 1 or Class 2 felonies but is subject to sentencing "as a Class X offender" (730 ILCS 5/5-5-3(c)(8) (West 1994)) because of prior criminal convictions.

BACKGROUND
In June 1997 defendant entered a negotiated plea of guilty to five counts of burglary (720 ILCS 5/19-1 (West 1994)).[1] Although burglary is a Class 2 offense (see 720 ILCS 5/19-1(b) (West 1994)), defendant was required to be sentenced as a Class X offender (see 730 ILCS 5/5-5-3(c)(8) (West 1994)) because of his prior convictions, which included numerous previous felony convictions for burglary and convictions for felony theft, reckless homicide and driving while license revoked, second offense. By the terms of his plea, defendant was sentenced to 15 years' imprisonment on each of the five counts of burglary in this case. The sentences on counts I and II ran concurrently with each other, as did the sentences on counts III, IV, and V. However, the 15-year terms on counts I and II ran consecutively to the *1237 15-year terms on counts III, IV, and V, resulting in an aggregate sentence of 30 years.
In July 1997 defendant moved to withdraw his guilty plea. With the assistance of counsel he later filed an amended motion. One of the contentions in the amended motion was that the 30-year sentence was void because it exceeded the maximum permissible term. The trial court denied the motion, and defendant appealed. The appellate court reversed the trial court's order. The court found that defendant was subject to a maximum sentence of 28 years, and accordingly the 30-year sentence was void. 304 Ill.App.3d 294, 237 Ill.Dec. 511, 709 N.E.2d 980. We granted the State's petition for leave to appeal (see 177 Ill.2d R. 315(a)), and now affirm the appellate court.

ANALYSIS
The issue in this case is whether defendant should have been allowed to withdraw his guilty plea. Leave to withdraw a plea of guilty is not granted as a matter of right, but as required to correct a manifest injustice under the facts involved. Generally, the decision whether to allow a defendant to withdraw a guilty plea under Rule 604(d) (145 Ill.2d R. 604(d)) is left to the discretion of the trial court. In considering such a motion, the court shall evaluate whether the guilty plea was entered through a misapprehension of the facts or of the law, or if there is doubt of the guilt of the accused and the ends of justice would better be served by submitting the case to a trial. See People v. Hillenbrand, 121 Ill.2d 537, 545, 118 Ill. Dec. 423, 521 N.E.2d 900 (1988). The court's decision is reviewed only for abuse of discretion. See People v. Gosier, 145 Ill.2d 127, 143, 163 Ill.Dec. 823, 582 N.E.2d 89 (1991); People v. Kidd, 129 Ill.2d 432, 447, 136 Ill.Dec. 18, 544 N.E.2d 704 (1989).
Defendant's primary contention is that he should have been allowed to withdraw his guilty plea because his sentence exceeded the maximum allowable sentence. If correct, this would constitute grounds for voiding defendant's guilty plea, because entering into a negotiated plea to serve a greater amount of time than that to which one could legally be sentenced would constitute a serious misapprehension of the law. Indeed, such a sentence would be void from inception. See People v. Arna, 168 Ill.2d 107, 113, 212 Ill.Dec. 963, 658 N.E.2d 445 (1995) (sentence which does not conform to a statutory requirement is void).
The determination of the maximum sentence to which defendant could properly be subjected turns on our interpretation of several sections of the Unified Code of Corrections (Code) (730 ILCS 5/1-1-1 et seq. (West 1994)). As previously noted, defendant committed five counts of burglary, a Class 2 offense. See 720 ILCS 5/19-1(b) (West 1994). At the time of defendant's offenses, section 5-8-4(c)(2) of the Code provided in relevant part that "the aggregate of consecutive sentences shall not exceed the sum of the maximum terms authorized under Section 5-8-2 [of the Code] for the 2 most serious felonies involved." 730 ILCS 5/5-8-4(c)(2) (West 1994). There is no dispute that section 5-8-4(c)(2) applied to defendant. Section 5-8-2 of the Code, referenced in section 5-8-4(c)(2), allows a sentence of up to 60 years for a Class X felony, or up to 14 years for a Class 2 felony. 730 ILCS 5/5-8-2(a)(2), (a)(4) (West 1994). Another statutory provision relevant to this case is section 5-5-3(c)(8) of the Code, which provides that:
"When a defendant, over the age of 21 years, is convicted of a Class 1 or Class 2 felony, after having twice been convicted of any Class 2 or greater Class felonies in Illinois, and such charges are separately brought and tried and arise out of different series of acts, such defendant shall be sentenced as a Class X offender. This paragraph shall not apply unless (1) the first felony was committed after the effective date of this amendatory Act of 1977; and (2) the second felony was committed after conviction *1238 on the first; and (3) the third felony was committed after conviction on the second." 730 ILCS 5/5-5-3(c)(8) (West 1994).
There is no dispute that defendant's prior convictions required him to be sentenced as a Class X offender pursuant to section 5-5-3(c)(8).
Our appellate court has reached different conclusions as to the maximum aggregate of consecutive sentences when a defendant commits multiple Class 1 or Class 2 felonies but must be sentenced as a Class X offender because of prior felonies. The First District and, in the case under review, the Third District have held that the maximum aggregate sentence must be based on the sentences permissible for a Class 1 or Class 2 felony, not a Class X felony. People v. Ritchey, 286 Ill.App.3d 848, 222 Ill.Dec. 439, 677 N.E.2d 973 (1997); 304 Ill.App.3d 294, 237 Ill.Dec. 511, 709 N.E.2d 980. The Fourth District, however, has held that where consecutive sentences are mandatory, a defendant who is subject to sentencing as a Class X offender pursuant to section 5-5-3(c)(8) may properly be sentenced to consecutive Class X terms. People v. Stencil, 306 Ill.App.3d 273, 239 Ill.Dec. 378, 713 N.E.2d 1228 (1999). The Stencil court acknowledged that its decision "arguably conflicts with the words of the statute," but held that "defendant's consecutive sentences in the Class X sentencing range are the punishments he deserves." Stencil, 306 Ill. App.3d at 279, 239 Ill.Dec. 378, 713 N.E.2d 1228. See also People v. Perkins, 274 Ill.App.3d 834, 836-37, 211 Ill.Dec. 422, 655 N.E.2d 325 (1995) (holding that because attempted murder is sentenced as a Class X felony, it is a Class X felony for purposes of section 5-8-4(a) of the Code (730 ILCS 5/5-8-4(a) (West 1994)) even though its offense level is unclassified and the Criminal Code defines unclassified offenses as Class 4 felonies).
In the exercise of statutory construction, our primary task is to ascertain and effectuate the intent of the legislature. In interpreting a statute we may consider the reason and necessity for the law, the evils it was intended to remedy, and its ultimate aims. Also, we must assume that the legislature did not intend an absurd or unjust result. However, our inquiry must always begin with the language of the statute, which is the surest and most reliable indicator of legislative intent. The language of the statute must be given its plain and ordinary meaning, and where the statutory language is clear and unambiguous, we have no occasion to resort to aids of construction. Nor, under the guise of statutory interpretation, can we "correct" an apparent legislative oversight by rewriting a statute in a manner inconsistent with its clear and unambiguous language. People v. Tucker, 167 Ill.2d 431, 437, 212 Ill.Dec. 664, 657 N.E.2d 1009 (1995); People v. Bole, 155 Ill.2d 188, 195-99, 184 Ill.Dec. 423, 613 N.E.2d 740 (1993).
As previously noted, there is no dispute that defendant's maximum sentence was "the sum of the maximum terms authorized under Section 5-8-2 for the 2 most serious felonies involved." The question is whether the maximum permissible sentence was 120 yearsthe sum of the maximum permissible extended-term sentences for two Class X offenses (730 ILCS 5/5-8-2(a)(2) (West 1994))or 28 years the sum of the maximum permissible extended-term sentences for two Class 2 offenses (730 ILCS 5/5-8-2(a)(4) (West 1994)). However, the two most serious felonies involved in this caseindeed, the only feloniesare burglaries. Our criminal code explicitly defines burglary as a Class 2 felony. 720 ILCS 5/19-1(b) (West 1994). This ends the case. Since burglary is a Class 2 felony, the maximum sentence for burglary is 14 years. 730 ILCS 5/5-8-2(a)(4) (West 1994). Accordingly, the maximum aggregate sentence was 28 years. Since defendant was given an aggregate sentence in excess of 28 years, his sentence was void. Arna, 168 Ill.2d at 113, 212 Ill.Dec. 963, 658 N.E.2d 445. Thus, the appellate court was correct to vacate *1239 defendant's guilty plea. See Hillenbrand, 121 Ill.2d at 545, 118 Ill.Dec. 423, 521 N.E.2d 900 (one ground for reversing trial court denial of motion to withdraw guilty plea is the plea having been entered through a misapprehension of the law).
The State urges us to reach a different conclusion based on section 5-5-3 of the Code, which, again, provides in essence that a defendant convicted of a Class 1 or Class 2 felony, who has previously twice been convicted of any Class 2 or greater Class felony in Illinois, must be sentenced "as a Class X offender." 730 ILCS 5/5-5-3(c)(8) (West 1994). The State contends that because defendant was to be sentenced as a Class X offender, his offenses should be treated as Class X felonies for purposes of determining the maximum permissible aggregate sentence. This argument ignores numerous previous decisions by this court as well as the plain language of section 5-5-3(c)(8), which states that persons subject to its provisions are to be "sentenced as a Class X offender," not that, e.g., their offenses are to be "treated as Class X felonies for sentencing purposes." Accordingly, this court has repeatedly held that section 5-5-3(c)(8) does not change the character or classification of the felonies committed. A defendant who commits a Class 1 or Class 2 felony, even though he is subject to sentencing as a Class X offender pursuant to section 5-5-3(c)(8), still has only committed a Class 1 or Class 2 felony. People v. Olivo, 183 Ill.2d 339, 340-41, 233 Ill.Dec. 661, 701 N.E.2d 511 (1998); People v. Thomas, 171 Ill.2d 207, 224, 215 Ill.Dec. 679, 664 N.E.2d 76 (1996); People v. Jameson, 162 Ill.2d 282, 290, 205 Ill.Dec. 90, 642 N.E.2d 1207 (1994) ("Under section 5-5-3(c)(8), a defendant's sentence is increased because of prior felony convictions, but the classification of offense with which the defendant is charged and convicted remains the same"). In this case, the two most serious felonies involved are two Class 2 felonies of burglary. Section 5-5-3(c)(8) does not change this fact.
The State attempts to distinguish Olivo on the basis that the statute at issue in that case referred to the most serious felonies of which defendant was "convicted," whereas section 5-8-4(c)(2) mentions the most serious felonies "involved." This argument does not address our long-standing construction of section 5-5-3(c)(8) as leaving unaffected the classification of a defendant's offense. We assume that the State is not advancing the contention that a defendant may be sentenced for felonies of which he was not convicted. We nevertheless find the argument without merit. The most serious felonies "involved" in this case are Class 2 burglaries. The fact that defendant was a recidivist does not change the character of the crimes he committed.
In Tucker, 167 Ill.2d 431, 212 Ill.Dec. 664, 657 N.E.2d 1009, the State also based an argument on the term "involved" in section 5-8-4(c)(2). There, we considered whether the aggregate consecutive sentence limitation applied to offenses committed at different times. The State argued that the only felonies "involved" were those charged as part of a single transaction. We concluded that the plain language of the statute did not support this interpretation and held that the limitation did apply to offenses committed at different times. We rejected the State's argument that this would lead to the "absurd result of allowing a defendant to escape criminal responsibility," noting that it was inherent in a limitation on consecutive sentencing that a defendant might escape punishment for one or more convictions. We concluded that as the legislature had seen fit to limit the total number of consecutive sentences that could be imposed on a defendant, we would not "rewrite the statute under the guise of statutory interpretation." Tucker, 167 Ill.2d at 437, 212 Ill.Dec. 664, 657 N.E.2d 1009. The legislature subsequently amended the statute to provide that the limitation would not apply "for offenses that were not committed as part of a single course of conduct during which there was no substantial change in *1240 the nature of the criminal objective." Pub. Act 90-128, § 5 (eff. July 22, 1997).
The State's final argument is based on "the policy considerations attendant to sentencing," citing People v. Lemons, 191 Ill.2d 155, 246 Ill.Dec. 116, 729 N.E.2d 489 (2000). There, we noted that the "`aim of recidivist statutes is to impose harsher sentences on offenders whose repeated convictions have shown their resistance to correction.'" Lemons, 191 Ill.2d at 160, 246 Ill.Dec. 116, 729 N.E.2d 489, quoting People v. Robinson, 89 Ill.2d 469, 476, 60 Ill.Dec. 632, 433 N.E.2d 674 (1982). However, the aim of section 5-8-4(c)(2) of the Code, and statutes like it, is "to limit the total length of consecutive sentences imposed on a defendant, while still fairly punishing the defendant in relation to the severity of the crimes." Tucker, 167 Ill.2d at 436, 212 Ill.Dec. 664, 657 N.E.2d 1009. Sections 5-5-3(c)(8) and 5-8-4(c)(2) of the Code serve different purposes, and the legislature has clearly and explicitly drawn the line as to where one policy consideration takes precedence over the other.
We recognize that it may seem somewhat anomalous for defendant to have been eligible for a longer sentence if sentenced "as a Class X offender" for a single crime than if he were subject to consecutive sentences for multiple crimes, which must normally be deemed a more serious situation. This may have been a legislative oversight. However, we are not at liberty to rewrite the statute in the guise of interpreting it. Tucker, 167 Ill.2d at 437, 212 Ill.Dec. 664, 657 N.E.2d 1009, Bole, 155 Ill.2d at 198-99, 184 Ill.Dec. 423, 613 N.E.2d 740. Additionally, because the limitation no longer applies to "offenses that were not committed as part of a single course of conduct during which there was no substantial change in the nature of the criminal objective" (Pub. Act 90-128, § 5 (eff. July 22, 1997)), the recidivist criminal element is already foreclosed from committing additional crimes in order to capitalize on the statutory anomaly.
The maximum length of consecutive sentences which may be imposed on a defendant is determined with reference to the classification of the felonies committed. 730 ILCS 5/5-8-4(c)(2), 5-8-2 (West 1994). The character and classification of the felonies a defendant has committed remain unchanged notwithstanding that he is subject to sentence enhancement under section 5-5-3(c)(8) of the Code. Olivo, 183 Ill.2d at 340-41, 233 Ill.Dec. 661, 701 N.E.2d 511; Thomas, 171 Ill.2d at 224, 215 Ill.Dec. 679, 664 N.E.2d 76; Jameson, 162 Ill.2d at 290, 205 Ill.Dec. 90, 642 N.E.2d 1207. Accordingly, in this case, defendant is subject to a maximum aggregate term of 28 years. Because the sentence imposed on him exceeds that length, it is void. Thus, the appellate court was correct in reversing the trial court's order denying defendant's motion to withdraw his guilty plea. Stencil, to the extent that it is inconsistent with our opinion, is overruled. Perkins, upon which the State also relies, is inapposite, in that it dealt with the classification of an unclassified felony (attempted murder), whereas in this case the legislature has explicitly classified burglary as a Class 2 felony. 720 ILCS 5/19-1(b) (West 1994). We note that the Perkins court found our opinion in Jameson had "no application" to the case before it. Similarly, Perkins has no application to the instant case.
Because of our determination that defendant is entitled to withdraw his guilty plea due to his sentence exceeding the statutory maximum, we need not address his alternate arguments.

CONCLUSION
For the reasons above stated, we affirm the judgment of the appellate court.
Affirmed.
NOTES
[1]  Defendant had initially pled not guilty to these charges. After a jury trial he was convicted of all five counts of burglary and sentenced to consecutive terms of 20 years' imprisonment on each count. However, the appellate court found he had received ineffective assistance of counsel and reversed his convictions. People v. Pullen, No. 3-96-0036 (April 16, 1997), 288 Ill.App.3d 1118, 238 Ill.Dec. 444, 711 N.E.2d 831 (unpublished order under Supreme Court Rule 23). Defendant's negotiated guilty plea followed the remand from the appellate court.
