delivered the opinion of the court:
Following a bench trial in the circuit court of Cook County, defendant was found guilty of the offense of unlawful use of weapons (Ill. Rev. Stat. 1983, ch. 38, par. 24 — 1(a)(2)), then sentenced to the penitentiary for a term of three years. Defendant now appeals from that judgment contending that he was improperly convicted of a felony offense where the State failed to allege his prior conviction in the indictment.
The record shows that the incident giving rise to the charge against defendant took place in the early morning hours of February 12, 1984, on the south side of Chicago. Five days after the incident, defendant entered a plea of guilty to the information which charged him with a weapons offense occurring within one year after his release from the Illinois Department of Corrections, where he had served a term for armed robbery. As a result of his plea, he was sentenced to a term of three years’ imprisonment.
On April 3, 1984, the trial court granted defendant’s motion to vacate this plea and the State sought to reinstate the charges through an indictment. A true bill was returned by the May grand jury, but the indictment was later found to be faulty, and evidence of the crime was presented to the August grand jury. The indictment which followed charged that defendant had committed the offense of unlawful use of weapons in that he:
“Unlawfully carried and possessed with intent to use against another, a dangerous knife, in violation of ch. 38, sec. 24— 1(a)(2) of the Illinois Revised Statutes 1983 as amended ***.”
Prior to trial, defendant filed a pro se motion to bar prosecution alleging, inter alia, that no police report relevant to the original charge ever existed, and that the indictment was based solely upon the testimony of an incompetent witness. Defendant’s motion was denied by the court, and the matter proceeded to trial.
At that time, Officer Ronald Condreva testified that about 5:30 *344a.m. on February 12, 1984, he and his partner, Daniel Lukensmeyer, received a call concerning a shooting on the street and responded to the area of 4724 South Shields. When they arrived at this location, there was no evidence of a crime, and the officers stepped out of their car to investigate. Lukensmeyer went up to the house, and Condreva approached defendant, whom he observed crouched down between two parked cars. Defendant stepped out into the street, reached into his coat pocket, and told the officer that he had better have his gun cocked. Condreva told him to stop, and as he reached for his gun, defendant took his hand out of his coat pocket, pointed a 13-inch butcher knife towards him and said, “Fuck you.” The officer called for his partner, and after a short struggle, defendant was disarmed and placed under arrest.
The State then rested its case in chief, and defense counsel made a motion for a directed finding. The court reserved its ruling on the motion, and defendant’s brother, Robert Vaughn, testified on behalf of his brother.
Vaughn stated that about 5:30 a.m. on the day in question, he heard noises emanating from the outside of his residence. When he looked out the window, he saw police officers shoving his brother between two cars parked on the street. At that time, he did not know that the man involved was his brother, and he did not see a knife in his brother’s hand nor guns drawn by the police.
Defendant testified that he was coming home from his girlfriend’s house that morning when police officers pulled up, ran into his yard with their guns drawn and accused him of calling them. He denied the accusation, but was placed in a squad car, handcuffed and taken to the station. He saw the police recover a knife from his yard, and when he was in custody was told by police that the knife was recovered from him. Defendant denied pointing a knife at the officers, threatening them, or directing abusive language at them. He did admit, however, that he had been convicted of armed robbery in 1980, and was currently on parole for that offense, and he knew that carrying a knife was a violation of parole.
The defense rested and Officer Lukensmeyer testified in rebuttal. He stated that when he and his partner arrived at the Shields address, he walked to within five feet of the door of the house when his partner called to him in an excited state. He turned and saw him struggling with the defendant in the street and helped apprehend defendant. Under examination by the court, he stated that he first saw defendant crouched between the cars when they pulled up, and that his partner walked towards defendant as he headed for the *345house.
The court denied defendant’s motion for a directed finding, and after hearing the arguments of counsel entered a finding of guilty. Defendant’s written motion for a new trial was also denied, and at the sentencing hearing which followed the State pointed out in aggravation that defendant had been convicted of armed robbery in 1981 and sentenced to eight years in the Illinois Department of Corrections. The State argued that he was eligible for an extended term of imprisonment and recommended a five-year sentence. Defense counsel noted that the court had defendant’s social and criminal histories before it, and requested that defendant be sentenced to a minimum term. Defendant was sentenced to three years’ imprisonment.
In this appeal from that judgment, defendant contends that he was improperly convicted of felonious unlawful use of weapons where the State failed to allege his prior conviction. Defendant argues that since there was no mention of the felony enhancement provision in the indictment, he was only charged with a misdemeanor, and consequently his felony sentence must be vacated and the cause remanded for resentencing on the misdemeanor conviction. The State initially responds that defendant has waived consideration of this issue by failing to include it in his post-trial motion; but notwithstanding the waiver, asserts that the assignment of error is without merit since defendant had sufficient notice that he was charged pursuant to the felony enhancement provision of the weapons statute and that he was not prejudiced by the omission of his prior felony conviction in the indictment.
At the outset we find the State’s waiver argument to be without merit. If the issue is correctly characterized by the State as a challenge to the sufficiency of the charging instrument, the State’s waiver argument is inappropriate, since it is well settled that such a challenge may be raised for the first time on review. (See, e.g., People v. Johnson (1979), 69 Ill. App. 3d 248, 387 N.E.2d 388.) Moreover, the waiver rule is a limitation on the parties and not on the courts, and a reviewing court may ignore a waiver where the interests of substantial justice so require. (People v. Walsh (1981), 101 Ill. App. 3d 1146, 428 N.E.2d 937.) In the instant case, the record shows that the issue was not raised at trial or in a post-trial motion; however, since the problem was not clearly evident until sentence was imposed, we do not believe defendant should be faulted for failing to include it in his prior written post-trial motion.
In order to secure a felony conviction for the offense of unlawful use of weapons, the State must not only prove a violation of section *34624 — 1(a) of the Criminal Code of 1961 of which defendant was charged, but under section 24 — 1(b) (Ill. Rev. Stat. 1983, ch. 38, par. 24 — 1(b)) it must also prove that this violation occurred within five years of a defendant’s felony conviction or within five years of his release from the penitentiary for a felony conviction. Without this additional proof, the offense is a misdemeanor. (People v. Palmer (1984), 104 Ill. 2d 340, 472 N.E.2d 795.)1 Accordingly, the supreme court has consistently held that it is necessary to allege and prove the prior felony conviction in order to establish the felony offense of unlawful use of weapons (People v. Palmer (1984), 104 Ill. 2d 340, 472 N.E.2d 795; People v. Dixon (1970), 46 Ill. 2d 502, 263 N.E.2d 876; People v. Owens (1967), 37 Ill. 2d 131, 225 N.E.2d 15), and that the proof of circumstances which render a misdemeanor a felony must come at trial before the finding of guilt or innocence. People v. Palmer (1984), 104 Ill. 2d 340, 472 N.E.2d 795; see also People v. Cook (1984), 129 Ill. App. 3d 531, 472 N.E.2d 856.
In the instant case it is clear that defendant’s prior conviction was not alleged in the indictment. Also, the State did not present any evidence to establish the enhancing element at trial. See People v. Cook (1984), 129 Ill. App. 3d 531, 472 N.E.2d 856.
Nevertheless, the State argues that the felony conviction should be affirmed since defendant had sufficient notice that he was charged pursuant to the felony enhancement provision of the unlawful use of weapons statute and was not prejudiced in any manner by the omission of his prior felony conviction. In support of this argument, the State relies primarily on the decision in People v. Hayes (1981), 87 Ill. 2d 95, 429 N.E.2d 490. In that case which involved a prosecution for felonious retail theft, the supreme court held that it was not necessary to allege in the charging instrument that the offense was a second or subsequent offense of retail theft where defendant had been advised at her first appearance before the court that the State sought to invoke the felony provisions of the statute, that the prior conviction had been stipulated at trial, and that defendant had shown no prejudice as a result of the State’s failure to allege the prior retail theft conviction in the information. Thus, unlike the instant case involving a weapons offense, an accused’s prior conviction for theft need not be alleged in the charging instrument since it only affects sentencing. The prior conviction is not an element of the offense of retail theft and therefore need not be proved before the trier of fact; *347it is sufficient if evidence of the prior conviction is presented during the sentencing hearing. See discussion in People v. Price (1984), 127 Ill. App. 3d 1, 3, 468 N.E.2d 412.
Moreover, even if we apply the principles of Hayes to the instant case, we do not believe that the felony conviction may be sustained. Here, it is not clear from the record that defendant was on notice that he was being tried for the felony offense. Although evidence of his prior conviction was presented to the grand jury after his initial plea to the felony offense was vacated, the indictment which followed did not contain any reference to the prior conviction. Moreover, at the start of trial, the parties clarified the status of the previous prosecution, and agreed that they were proceeding solely on the indictment returned after this proceeding.
In addition, we believe the following colloquy, which occurred during defense counsel’s cross-examination of the State’s main witness, further evidences the understanding that the parties were proceeding on the charge as stated in the indictment.
“[Defense counsel]: Officer, at what point did you first determine the criminal history of the defendant?
[Prosecutor]: Objection to relevance.
THE COURT: The charge is not related to prior criminal history of the defendant at all.
[Defense counsel]: Yes I understand that judge.
THE COURT: How is it relevant?
[Defense counsel]: I’m trying to find out at what point — the officer said he first found out the address of Mr. Vaughn at the police station. I have reason to believe he found out earlier, and I’m just trying to determine whether that is true or not.
THE COURT: Fine. You can answer.”
It is difficult to believe that defense counsel would have elicited testimony concerning defendant’s prior conviction at trial when the State had not presented any evidence of it if he thought the State was proceeding on the felony charge.
Furthermore, there was no reference to the prior conviction during closing argument, and when the court announced its finding of guilt, it did not specify or refer to any offense other than the one contained in the indictment. Although in this appeal defendant has not contested the proof to establish the offense and the matter was tried before the bench, we find it arguable that the evidence of defendant’s conviction at trial related to his credibility and was to be considered only for that purpose. (See People v. Edwards (1976), 63 Ill. 2d 134, 345 N.E.2d 496.) We also recognize that no objection was raised to *348the felony sentence imposed by the court at the sentencing hearing; however, under the circumstances peculiar to this case, we believe that defendant should be given the benefit of the doubt appearing in the record and not bear the consequences caused by the obvious omission in the charging instrument.
As noted above, the supreme court has consistently held through a long line of cases from People v. Ostrand (1966), 35 Ill. 2d 520, 221 N.E.2d 499, to the recent decision in Palmer, that a prior conviction within the terms set forth in the weapons statute is an element of the felonious offense of unlawful use of weapons which must be alleged and proved at trial. In our opinion, this standard was not met in the instant case, and accordingly, we reduce the degree of the offense to a misdemeanor and remand the cause to the circuit court for resentencing on this conviction. 87 Ill. 2d R. 615(b).
The judgment of the circuit court is affirmed as modified and the cause is remanded.
Affirmed as modified and remanded.
MEJDA, P.J., and SULLIVAN, J., concur.