
800 N.E.2d 436 (2003)
343 Ill. App.3d 889
279 Ill.Dec. 368
The PEOPLE of the State of Illinois, Plaintiff-Appellee,
v.
Frank WASHINGTON, Defendant-Appellant.
No. 1-02-2919.
Appellate Court of Illinois, First District, Third Division.
September 30, 2003.
Rehearing Denied November 12, 2003.
*438 Michael J. Pelletier, Deputy Appellate Defender of the State of Illinois (Tomas G. Gonzalez, Assistant Appellate Defender, of counsel), for Appellant.
Richard A. Devine, State's Attorney of Cook County (Renee Goldfarb, William L. Toffenetti, of counsel), for Appellee.
Justice KARNEZIS delivered the opinion of the court:
Following a bench trial, defendant Frank Washington was convicted of aggravated unlawful use of a weapon (aggravated UUW) (720 ILCS 5/24-1.6(a)(1)(3)(A) (West 2000)) and possession of a controlled substance (720 ILCS 570/402(c) (West 2000)). Defendant was sentenced to nine years' imprisonment for aggravated unlawful use of a weapon and three years' imprisonment for possession of a controlled substance, to be served concurrently. On appeal, defendant argues: (1) the aggravated UUW statute violates substantive due process; (2) the aggravated UUW statute violates the proportionate penalties clause when compared to reckless discharge of a firearm; (3) the State failed to prove defendant guilty of possession of a controlled substance beyond a reasonable doubt; and (4) the State failed to prove, beyond a reasonable doubt, the factors used to extend his sentence. We affirm.

BACKGROUND
We will discuss only those facts relevant to the disposition of this appeal.
On November 14, 2001, after being alerted to possible narcotics transactions, Officer Lanell Aubert of the Chicago police department, with his partners Officers Madison and Green, set up surveillance of a residence at 6040 South Wood Street. Officer Aubert had an unobstructed view of the residence from his post across the street at 6033 South Wood Street and could see defendant, whom he later identified in court, standing on the sidewalk in front of 6040 South Wood Street.
Officer Aubert testified that as he was watching, he saw an unidentified individual hand defendant a sum of money. After receiving the money, defendant *439 walked toward the gangway, pulled back some aluminum siding from the facade of the residence and retrieved a plastic bag. Defendant retrieved a smaller item from the larger plastic bag and then returned the plastic bag underneath the aluminum siding. Defendant returned to the individual and handed him the small item he had retrieved from the plastic bag. The individual then walked off. Two other individuals approached defendant on two separate occasions and the aforementioned process was repeated.
After the third transaction, Officer Aubert radioed his partners and informed them of his observations. After Officers Madison and Green had detained defendant, Officer Aubert entered the gangway and looked under the aluminum siding where he had seen defendant retrieve the large plastic bag. There, Officer Aubert discovered a plastic bag containing smaller items which he suspected were cocaine.
Officer Madison testified that after he was alerted by Officer Aubert regarding the narcotics transactions Officer Aubert had witnessed, he and Officer Green approached 6040 South Wood in their unmarked vehicle. As he was exiting his vehicle to approach defendant, Officer Madison observed defendant remove a blue, steel weapon from his waistband and throw the weapon to the ground. Defendant was taken into custody and the gun was recovered. Officer Madison found that the weapon contained one live round and one spent round. In addition, it was later discovered that defendant did not have a valid firearm owner's identification card (FOID).
The parties then stipulated that Officer Aubert inventoried the recovered two items of suspected cocaine that he had recovered from the plastic bag found in the facade of the residence and that there was a proper chain of custody maintained at all times over the recovered items.
The parties also stipulated that if called to testify, forensic chemist Brister, who is employed by the Illinois State Police crime lab and qualified as an expert in the area of forensic chemistry, would testify that he received the items recovered by Officer Aubert in a sealed condition. He weighed the two items of suspected cocaine and discovered that the total estimated weight of the recovered items was 0.2 grams. He then performed tests, commonly accepted in the area of forensic chemistry for ascertaining the presence of a controlled substance, on the two items and opined within a reasonable degree of scientific certainty that the items tested positive for the presence of cocaine.
Following this testimony and the testimony of several defense witnesses, the court found defendant of guilty aggravated UUW and possession of a controlled substance. It is from this judgment that defendant now appeals.

ANALYSIS

A. Substantive Due Process
Defendant first attacks the constitutionality of the aggravated UUW statute and argues that it violates substantive due process because it lacks a culpable mental state and punishes innocent conduct. We recently considered and rejected this argument in People v. Grant, 339 Ill.App.3d 792, 274 Ill.Dec. 304, 791 N.E.2d 100 (2003). In Grant, this court held that the aggravated UUW statute does, in fact, contain a sufficient mental state, i.e., knowledge, and does not violate substantive due process as it is rationally related to legitimate state goals. Grant, 339 Ill. App.3d at 806, 274 Ill.Dec. 304, 791 N.E.2d at 111-12; see also People v. McGee, 341 Ill.App.3d 1029, 276 Ill.Dec. 605, 794 *440 N.E.2d 855 (2003); People v. Marin, 342 Ill.App.3d 716, 277 Ill.Dec. 285, 795 N.E.2d 953 (2003).

B. Proportionate Penalties
Defendant contends that the aggravated unlawful use of a weapon statute (720 ILCS 5/24-1.6 (West 2000)), which is a Class 2 felony when a defendant has a previous felony conviction, violates the proportionate penalties clause of the Illinois Constitution when compared to the reckless discharge of a firearm statute (720 ILCS 5/24-1.5 (West 2000)), which is always a Class 4 felony.
The aggravated UUW statute provides:
"(a) A person commits the offense of aggravated unlawful use of a weapon when he or she knowingly:
(1) Carries on or about his or her person or in any vehicle or concealed on or about his or her person except when on his or her land or in his or her abode or fixed place of business any pistol, revolver, stun gun or taser or other firearm; or
(2) Carries or possesses on or about his or her person, upon any public street, alley, or other public lands within the corporate limits of a city, village or incorporated town, except when an invitee thereon or therein, for the purpose of the display of such weapon or the lawful commerce in weapons, or except when on his or her own land or in his or her own abode or fixed place of business, any pistol, revolver, stun gun or taser or other firearm; and
(3) One of the following factors is present:
(A) the firearm possessed was uncased, loaded and immediately accessible at the time of the offense; or
(B) the firearm possessed was uncased, unloaded and the ammunition for the weapon was immediately accessible at the time of the offense; or
(C) the person possessing the firearm has not been issued a currently valid Firearm Owner's Identification Card; or
(D) the person possessing the weapon was previously adjudicated a delinquent minor under the Juvenile Court Act of 1987 for an act that if committed by an adult would be a felony; or
(E) the person possessing the weapon was engaged in a misdemeanor violation of the Cannabis Control Act or in a misdemeanor violation of the Illinois Controlled Substances Act; or
(F) the person possessing the weapon is a member of a street gang or is engaged in street gang related activity, as defined in Section 10 of the Illinois Streetgang Terrorism Omnibus Prevention Act; or
(G) the person possessing the weapon had a[n] order of protection issued against him or her within the previous 2 years; or
(H) the person possessing the weapon was engaged in the commission or attempted commission of a misdemeanor involving the use or threat of violence against the person or property of another; or
(I) the person possessing the weapon was under 21 years of age and in possession of a handgun as defined in Section 24-3, unless the person under 21 is engaged in lawful activities under the Wildlife Code or described in subsection 24-2(b)(1), (b)(3), or 24-2(f).
* * *
(c) This Section does not apply to or affect the transportation or possession of weapons that:
(i) are broken down in a non-functioning state; or
(ii) are not immediately accessible; or

*441 (iii) are unloaded and enclosed in a case, firearm carrying box, shipping box, or other container by a person who has been issued a currently valid Firearm Owner's Identification Card. (d) Sentence. Aggravated unlawful use of a weapon is a Class 4 felony; a second or subsequent offense is a Class 2 felony. Aggravated unlawful use of a weapon by a person who has been previously convicted of a felony in this State or another jurisdiction is a Class 2 felony." 720 ILCS 5/24-1.6 (West 2002).
Conversely,
"(a) A person commits the offense of reckless discharge of a firearm by discharging a firearm in a reckless manner which endangers the bodily safety of an individual.
(b) If the conduct described in subsection (a) is committed by a passenger of a moving motor vehicle with the knowledge and consent of the driver of the motor vehicle the driver is accountable for such conduct.
(c) Reckless discharge of a firearm is a Class 4 felony.
(d) This Section does not apply to a peace officer while in the performance of his or her official duties." 720 ILCS 5/24-1.5 (West 2002).
The proportionate penalties clause provides "[a]ll penalties shall be determined both according to the seriousness of the offense and with the objective of restoring the offender to useful citizenship." Ill. Const.1970, art. I, § 11. Our supreme court has recognized three instances in which a violation of the proportionate penalties clause may occur:
"First, the proportionate penalties clause is violated where the punishment for a particular offense is cruel, degrading, or so wholly disproportionate to the offense as to shock the moral sense of the community. [Citation.] Second, the proportionate penalties clause is violated where similar offenses are compared and conduct that creates a less serious threat to the public health and safety is punished more harshly. [Citation.] Third, the proportionate penalties clause is violated where identical offenses are given different sentences." People v. Davis, 177 Ill.2d 495, 503-04, 227 Ill. Dec. 101, 687 N.E.2d 24, 28 (1997).
In the case at bar, defendant has employed the second, or cross-comparison, test in comparing the aggravated UUW statute with the reckless discharge statute. When considering a possible proportionate penalties violation by cross-comparison, courts are obligated to make a two-pronged inquiry: (1) whether the statutory purposes of the compared offenses are so distinct that comparative proportionality review is not appropriate; and (2) whether the offense with the harsher penalty is more serious than the offense with the less severe penalty. People v. Lombardi, 184 Ill.2d 462, 475-76, 235 Ill.Dec. 478, 705 N.E.2d 91, 98 (1998), citing Davis, 177 Ill.2d at 506, 227 Ill.Dec. 101, 687 N.E.2d at 24. With respect to the first step, comparative proportionality review is inappropriate when the statutory purposes are different because, where statutes are enacted for different reasons, we must presume that the legislature considered different factors in crafting the respective punishments. Lombardi, 184 Ill.2d at 476, 235 Ill.Dec. 478, 705 N.E.2d at 99. With regard to the second step in the cross-comparison inquiry, the proportionate penalties clause is violated "if the penalty prescribed for a less serious offense is greater than the penalty prescribed for a more serious offense." People v. Lee, 167 Ill.2d 140, 144, 212 Ill.Dec. 231, 656 N.E.2d 1065, 1067 (1995), citing People v. Wisslead, *442 94 Ill.2d 190, 196, 68 Ill.Dec. 606, 446 N.E.2d 512, 514 (1983).
Defendant argues that aggravated UUW and reckless discharge of a firearm share a common statutory purpose, which is to protect the public from the misuse of firearms. Therefore, defendant maintains, the only issue for this court to review is whether the offense with the harsher penalty, aggravated UUW, is less serious than the offense with the less severe penalty, reckless discharge of a firearm.
The State responds and contends that proportionality review is inappropriate because the statutes in question were enacted for different legislative purposes. The State maintains that the purpose of the aggravated UUW statute is to protect the safety of those in public places. Conversely, the reckless discharge of a firearm statute protects individuals on both public and private lands.
Neither statute in question here states the purpose of the statute in the statute itself. Therefore, we must look to the histories of the statutes and the language of the statutes themselves for guidance in determining their purposes. People v. Donoho, 204 Ill.2d 159, 173-74, 273 Ill.Dec. 116, 788 N.E.2d 707, 716-17 (2003); People v. Hill, 199 Ill.2d 440, 456, 264 Ill.Dec. 670, 771 N.E.2d 374, 384 (2002).
In Grant, we discussed the legislative purpose of the aggravated UUW statute. Specifically, we stated:
"[b]ased on the legislative transcript, it is clear that the goal of the legislature in enacting the aggravated unlawful use of a weapon statute (720 ILCS 5/24-1.6 (West 2000)) was to allow the State to seek a harsher penalty for any person in the State of Illinois, who does not fall under a specific exemption, from carrying a loaded weapon in the passenger compartment of his or her vehicle because of the inherent dangers to police officers and the general public." Grant, 339 Ill.App.3d at 806, 274 Ill.Dec. 304, 791 N.E.2d at 110.
See also People v. McGee, 341 Ill.App.3d 1029, 276 Ill.Dec. 605, 794 N.E.2d 855 (2003); People v. Marin, 342 Ill.App.3d at 716, 277 Ill.Dec. 285, 795 N.E.2d at 962-63 (2003) (acknowledging the inherent dangers in one carrying a loaded, concealed weapon on his person.)
The legislative transcripts reveal that the purpose of the reckless discharge of a firearm statute is to address the issue of drive-by shootings:
"if the person fires it [a weapon] at somebody or shoots it into a building that's occupied, under current law it would be a Class I felony because it would become aggravated discharge of a firearm. But what if somebody just recklessly discharges a firearm? Doesn't necessarily aim it at someone of aim it into a [sic] occupied building, but goes around town or out in the country or wherever it is shooting off a gun recklessly, with reckless abandon? Under current law, that would be a Class A misdemeanor. * * * It [the statute] fills in a void . . . that's currently in the law." 88th Ill. Gen. Assem., House Proceedings, April 22, 1993 at 210 (statements of Representative Homer).
The statute was intended to clarify a "loophole" then existing in Illinois law, where an individual could escape felony charges for his involvement in a drive-by shooting simply because he was acting recklessly, rather than knowingly. 88th Ill. Gen. Assem., House Proceedings, April 22, 1993 at 209 (statements of Representative Dart). In addition, the statute allows for felony charges of reckless discharge of a firearm to be brought against the driver of the vehicle, even if he did not commit the overt act of firing the weapon, where previously *443 the driver would escape criminal liability. 88th Ill. Gen. Assem., House Proceedings, April 22, 1993 at 203 (statements of Representative Martinez), 209 (statements of Representative Dart), 209-10 (statements of Representative Homer).
Both statutes in question here are a result of our legislature's acknowledgment of the dangers associated with firearms. However, this generality does not overcome the fact that the aggravated UUW statute and the reckless discharge of a firearm statute have distinctly different legislative purposes: the aggravated UUW statute to prevent persons from knowingly carrying loaded, concealed, and easily accessible weapons on their persons or in the passenger compartments of their vehicles; the reckless discharge of a firearm statute to prevent the reckless, not knowing or intentional, discharge of a firearm out of a motor vehicle. Quite simply, one (aggravated UUW) is targeted at possession of a weapon and the other (reckless discharge of a firearm) is targeted at use of a weapon.
Because of these distinct differences, we must presume that the legislature considered different factors in crafting the respective punishments. Lombardi, 184 Ill.2d at 476, 235 Ill.Dec. 478, 705 N.E.2d 91. As such, comparative proportionality review is inappropriate in this case and we need not address whether the offense with the harsher penalty is more serious than the offense with the less severe penalty. Lombardi, 184 Ill.2d at 476, 235 Ill.Dec. 478, 705 N.E.2d 91.

C. Reasonable Doubt
Defendant argues that the evidence was insufficient to prove him guilty of possession of a controlled substance beyond a reasonable doubt. When a defendant is challenging the sufficiency of the evidence, the relevant inquiry is whether, after viewing all of the evidence in the light most favorable to the prosecution, any rational trier of fact could have found the essential elements of the crime beyond a reasonable doubt. People v. Smith, 185 Ill.2d 532, 541, 236 Ill.Dec. 779, 708 N.E.2d 365, 369 (1999). We may not substitute our judgment for that of the trial court and will not reverse a conviction unless the evidence is so improbable or unsatisfactory that it creates a reasonable doubt of defendant's guilt. People v. Lundy, 334 Ill.App.3d 819, 825, 268 Ill.Dec. 790, 779 N.E.2d 404, 410 (2002), citing People v. Clemons, 277 Ill. App.3d 911, 923, 214 Ill.Dec. 622, 661 N.E.2d 476, 484 (1996).
To sustain a conviction for possession of a controlled substance, the State is required to prove that the substance recovered is in fact a controlled substance. People v. Hagberg, 192 Ill.2d 29, 31, 248 Ill.Dec. 273, 733 N.E.2d 1271, 1272 (2000). Defendant maintains that the evidence in this case was insufficient to support such a finding. As previously discussed, the parties stipulated to the testimony of forensic chemist Brister. The parties stipulated that Brister would testify that he received the items recovered by Officer Aubert in a sealed condition, weighed the items and determined that the total estimated weight of the recovered items was 0.2 grams. He then performed tests on the two items commonly accepted in the area of forensic chemistry for ascertaining the presence of a controlled substance and opined within a reasonable degree of scientific certainty that the items tested positive for the presence of cocaine.
Specifically, defendant complains of the stipulated testimony in that the State failed to: (1) identify what tests were performed; (2) indicate that any equipment used in performing the tests was functioning properly at the time of the testing; or (3) explain why the chemist knew the results were accurate. Thus, the State's failure *444 to prove the above rendered the chemist's opinion insufficient to prove beyond a reasonable doubt that the substance in question was cocaine.
The State asserts that defendant has waived consideration of this issue on appeal because he did not object at trial. While normally a defendant who fails to object at trial and fails to raise the issue in a posttrial motion waives the issue for purpose of appeal (People v. Enoch, 122 Ill.2d 176, 186, 119 Ill.Dec. 265, 522 N.E.2d 1124, 1129 (1988)), when a defendant is complaining of an error, even though based on a stipulation, that goes to the sufficiency of the evidence, it is not subject to the waiver rule. People v. Rucker, No. 1-01-3617, ___ Ill.App.3d ___, ___, 280 Ill.Dec. 801, 803 N.E.2d 31, 2003 WL 21976372 (August 19, 2003), citing People v. Cowans, 336 Ill.App.3d 173, 175-76, 270 Ill.Dec. 220, 782 N.E.2d 779 (2002). Therefore, we consider defendant's claim.
Defendant relies on the holding in People v. Raney, 324 Ill.App.3d 703, 258 Ill.Dec. 356, 756 N.E.2d 338 (2001), to support his position that the evidence is insufficient in this case. In Raney, defendant was convicted of possession with intent to deliver after officers recovered a plastic bag containing 14 smaller bags which contained cocaine. A forensic scientist was called by the State at trial to establish that the content of the 14 small bags was cocaine. The scientist testified that she weighed the evidence and then performed a colbalt thiocyanate color test, which is similar to a field test. The scientist then performed a test with the gas chromatography mass spectrometer machine (GCMS) and concluded that the 14 packets contained cocaine. Raney, 324 Ill.App.3d at 705, 258 Ill.Dec. 356, 756 N.E.2d at 340.
Raney complained on appeal that the State failed to prove him guilty beyond a reasonable doubt because the State failed to establish a proper foundation for the admission of the scientific results from the GCMS machine. This court agreed with Raney, finding that the scientist did not: (1) provide any foundation proof as to the method of recording the information provided by the GCMS machine; (2) the scientist did not provide any foundation proof that the GCMS machine was working properly at the time it was used; and (3) the scientist failed to explain how the machine was calibrated or why she knew the results were accurate. Raney, 324 Ill.App.3d at 710, 258 Ill.Dec. 356, 756 N.E.2d at 344.
We find Raney distinguishable from the instant case because Raney did not involve stipulated evidence. A criminal defendant may waive, by stipulation, the need to prove all or part of the case that the State has brought against him. People v. Polk, 19 Ill.2d 310, 315, 167 N.E.2d 185, 188 (1960). A stipulation entered into by parties in a narcotics case may serve to "remove from the case any issue of the expert's qualifications, the chain of custody, or the weight and chemical composition of the suspect materials." People v. Williams, 200 Ill.App.3d 503, 516, 146 Ill.Dec. 298, 558 N.E.2d 261, 269 (1990). A defendant is precluded from attacking or opposing any facts to which he has previously stipulated. People v. Gibson, 287 Ill.App.3d 878, 880, 223 Ill.Dec. 234, 679 N.E.2d 419, 420 (1997).
The facts of the case at bar can be best compared to those in People v. Rucker, No. 1-01-3617, ___ Ill.App.3d ___, 280 Ill.Dec. 801, 803 N.E.2d 31, 2003 WL 21976372 (August 19, 2003). Rucker, who had been found guilty of possession of a controlled substance with intent to deliver, made the precise allegations regarding the sufficiency of the evidence on appeal that defendant makes here. That is, that the *445 State failed to: "`(1) identify what tests were performed; (2) indicate that any equipment was used in performing the tests was functioning properly at the time of the testing; or (3) explain why the chemist knew [the] results were accurate.'" Rucker, ___ Ill.App.3d at ___, 280 Ill.Dec. 801, 803 N.E.2d 31. Similarly, Rucker raised these issues on appeal after he stipulated to the testimony of a forensic chemist at trial. Rucker, ___ Ill.App.3d at ___, 280 Ill.Dec. 801, 803 N.E.2d 31.
The Rucker court rejected the defendant's argument finding that the parties stipulated to an adequate foundation and that the stipulated evidence was sufficient to support the finding that the substance possessed by the defendant was cocaine. Rucker, ___ Ill.App.3d at ___, 280 Ill.Dec. 801, 803 N.E.2d 31. The court based its ruling on the fact that the parties stipulated not only that the chemist was "`qualified to testify as an expert in the area of forensic chemistry,'" but that she also "`performed tests commonly accepted in the area of forensic chemistry for ascertaining the presence of a controlled substance.' "Rucker, ___ Ill.App.3d at ___, 280 Ill.Dec. 801, 803 N.E.2d 31. Furthermore the court reasoned:
"[B]ased on the strength of these agreed facts, it was reasonable and fair for the trier of fact to conclude that the chemist followed basic scientific procedure, such as testing the proper functioning of any mechanical devices she used, and that it was the intent of the parties to stipulate to this fact. If it had not been the intent of the parties to stipulate to this fact, it would have been in their best interests not to agree to the stipulation." Rucker, ___ Ill.App.3d at ___-___, 280 Ill.Dec. 801, 803 N.E.2d 31.
Likewise, in the case at bar, the parties stipulated that forensic chemist Brister was "qualified to testify as an expert in the area of forensic chemistry." It was also stipulated that she performed "tests commonly accepted in the area of forensic chemistry for ascertaining the presence of a controlled substance." Furthermore, it was reasonable and fair for the trial court in this case to conclude that the parties intended to stipulate that the chemist followed basic scientific procedure, including ascertaining that the devices she used were properly functioning at the time the tests were performed. We therefore conclude that the evidence in this case is sufficient to support a finding that defendant illegally possessed cocaine.

D. Extended-Term Sentence
Defendant challenges the propriety of the nine-year sentence imposed in his case. Specifically, defendant argues that the trial court improperly sentenced him to an extended-term sentence based on his prior convictions, without finding that those convictions were proven beyond a reasonable doubt as required by section 5-8-2 of the Unified Code of Corrections (730 ILCS 5/5-8-2 (a)(6) (West 2000)).
Aggravated unlawful use of a weapon (720 ILCS 5/24-1.6 (West 2000)) is a Class 4 felony, punishable by a sentence of not less than one year's and not more than three years' imprisonment (730 ILCS 5/5-8-1(a)(7) (West 2000)). However, a "second or subsequent offense is a Class 2 felony. Aggravated unlawful use of a weapon by a person who has been previously convicted of a felony in this State or another jurisdiction is a Class 2 felony." 720 ILCS 5/24-1.6(d) (West 2000). A Class 2 felony is punishable by a sentence of not less than three years and not more than seven years. 730 ILCS 5/5-8-1(a)(2.5)(5) (West 2000). Furthermore, a *446 defendant, who is convicted of a Class 2 felony may receive an extended-term sentence of not less than 7 years and not more than 14 years when the defendant has been:
"convicted of any felony, after having been previously convicted in Illinois or any other jurisdiction of the same or similar class felony or greater class felony, when such conviction has occurred within 10 years after the previous conviction, excluding time spent in custody, and such charges are separately brought and tried and arise out of different series of acts." 730 ILCS 5/5-5-3.2(b)(1), 5-8-2(a)(4) (West 2000).
As a result of the rule announced by the United States Supreme Court in Apprendi v. New Jersey, 530 U.S. 466, 490, 120 S.Ct. 2348, 2362-63, 147 L.Ed.2d 435, 455 (2000), which stated that "[o]ther than the fact of a prior conviction, any fact that increases the penalty for a crime beyond the prescribed statutory maximum must be submitted to a jury, and proved beyond a reasonable doubt," many of the statutes that comprised Illinois's sentencing scheme could no longer be constitutionally applied to criminal defendants. In response, the Illinois legislature codified the rule announced in Apprendi by adopting Public Act 91-953 (Pub. Act 91-953 eff. February 23, 2001), which made several changes to the Unified Code of Corrections. Pertinent to this appeal are the amendments made to section 5-8-2. Effective February 23, 2001, section 5-8-2 read:
"(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 a trier of fact finds beyond a reasonable doubt that such factors were present, the judge may sentence an offender to the following:
* * *
(4) for a Class 2 felony, a term shall be not less than 7 years and not more than 14 years[.]" 730 ILCS 5/5-8-2 (West 2000).
Defendant suggests that, based on the language of section 5-8-2 on the date that the crime in question was committed, November 14, 2001, the trial court could not impose an extended-term sentence based on his prior convictions without finding that those convictions were proven beyond a reasonable doubt.[1] The State disagrees and asserts that the legislature's failure to include the exception for extended-term sentences based on prior convictions in section 5-8-2 was merely an oversight. In support of its position, the State urges us to look at Public Act 91-953 in it's entirety and to follow the clear legislative intent.
*447 The primary consideration in construing a statute is to give effect to the intent of the legislature. People v. Scott, 57 Ill.2d 353, 358, 312 N.E.2d 596, 599 (1974). In determining the intent of the legislature, courts are not confined to a literal interpretation of the statutory language. In re Pronger, 118 Ill.2d 512, 520, 115 Ill.Dec. 390, 517 N.E.2d 1076, 1078 (1987). Rather, the court may look to the reason and necessity for the law and the evils that the legislature sought to remedy. People v. Jeffries, 164 Ill.2d 104, 110, 207 Ill.Dec. 21, 646 N.E.2d 587, 589 (1995). In addition, courts may properly consider both the history and course of the legislation and subsequent amendments to the statute. Kirwan v. Welch, 133 Ill.2d 163, 165, 139 Ill.Dec. 836, 549 N.E.2d 348, 349 (1989); People v. Beam, 74 Ill.2d 240, 242-43, 24 Ill.Dec. 157, 384 N.E.2d 1315, 1316 (1979). In doing so, courts may insert language into a statute that has been omitted through legislative oversight. People v. Chandler, 129 Ill.2d 233, 253, 135 Ill.Dec. 543, 543 N.E.2d 1290, 1298 (1989).
In People v. Askew, 341 Ill.App.3d 548, 554, 275 Ill.Dec. 576, 793 N.E.2d 56 (2003), the first division of this court considered the precise question before us here: whether the absence of an exemption for prior convictions in section 5-8-2(a) was legislative oversight. After reviewing Public Act 91-953 in it's entirety, we agree with the holding in Askew that the legislature clearly intended to make amendments to all of the necessary sections of the Unified Code of Corrections to comport with the rule announced in Apprendi. We recognize that statutes must be strictly construed in favor of the accused. Chandler, 129 Ill.2d at 254, 135 Ill.Dec. 543, 543 N.E.2d at 1299. This rule does not require us, however, to so rigidly construe a statute as to defeat the intent of the legislature or to arrive at an absurd result. Chandler, 129 Ill.2d at 253, 135 Ill.Dec. 543, 543 N.E.2d at 1298.
Considering the clear intent of the legislature, it would be unlikely that the legislature purposely ignored the recidivist exception articulated by the Apprendi Court when it amended section 5-8-2 to require that, when used as aggravating factors to extend a sentence, prior criminal convictions must be proven beyond a reasonable doubt. 730 ILCS 5/5-8-2 (West 2000). Other amendments effectuated by Public Act 91-953 clearly indicate that the legislature intended to and actually was successful in codifying the recidivism exception to the Apprendi rule. See 725 ILCS 5/111-3(c-5) (West 2001); 730 ILCS 5/5-5-3(a), 5-5-4 (West 2000). In addition, subsequent to adopting the changes promulgated by Public Act 91-953, the legislature recognized the omission in section 5-8-2 and cured the oversight by again amending section 5-8-2. Public Act 92-591 (Pub. Act 92-951, eff. June 27, 2002), amended section 5-8-2 by excluding the language "[w]here a trier of fact finds beyond a reasonable doubt that such factors were present" that had previously been added by Public Act 91-953. Therefore, we hold that defendant's nine-year extended-term sentence need not be vacated.
Based on the foregoing, the judgment of the trial court is affirmed.
Affirmed.
HOFFMAN, P.J., and SOUTH, J., concur.
NOTES
[1]  Defendant was arrested for this offense on November 14, 2001, and was sentenced for this offense on August 6, 2002. A defendant is entitled to be sentenced under either the law in effect at the time of the offense or that in effect at the time of his sentencing. People v. Hollins, 51 Ill.2d 68, 71, 280 N.E.2d 710 (1972). Public Act 92-591, section 5, effective June 27, 2002, modified the existing language in 5-8-2 and provides that an extended-term sentence is appropriate "[i]f the pre-trial and trial proceedings were conducted in compliance with subsection (c-5) of Section 111-3 of the Code of Criminal Procedure of 1963 [725 ILCS 5/111-3 (West 2002)]." 730 ILCS 5/5-8-2(a) (West 2002). There is no indication in the record whether defendant elected to be sentenced according to section 5-8-2 as amended by Public Act 91-953, effective February 23, 2001, or by section 5-8-2 as amended by Public Act 92-591, effective June 27, 2002.
