The opinion of the court was delivered by
BRODY, P.J.A.D.The issue is whether the court may impose a Graves-Act (firearm) mandatory extended prison term, reserved for second offenders, on a person who did not receive an extended term when first sentenced because the prior conviction of a Graves-Act offense was then on appeal. We now hold that once the prior conviction has been affirmed, the trial court may correct the original sentence and impose the extended term mandated by statute.
Defendant was convicted of first-degree armed robbery. He committed the crime with a firearm and was subject to a mandated extended prison term because he previously had been convicted of another armed robbery with a firearm. N.J.S.A. 2C:43-6c. However, his appeal of the earlier conviction was pending when he was sentenced for the present offense. Despite the appeal, the trial judge imposed an extended prison term of fifty years, seventeen years to be served before parole eligibility. We vacated the *159sentence in an unreported opinion and remanded for resentencing because the prior conviction could not be considered as the basis for an extended prison term while its appeal was pending. N.J.S.A. 2C:44-4b; State v. Mangrella, 214 N.J.Super. 437, 443, 519 A.2d 926 (App.Div.1986), certif. denied 107 N.J. 127, 526 A.2d 194 (1987).
Upon remand, the trial judge resentenced defendant to an ordinary prison term. Thereafter, the State moved to correct the sentence as illegal after we affirmed the prior conviction and defendant did not seek certification in the Supreme Court. The trial judge granted the State’s motion and imposed the original extended prison term. Defendant argues generally that to permit correction of the sentence violates “[cjonsiderations of fundamental fairness.” We disagree.
The Legislature intended that a Graves-Act offender previously convicted of a Graves-Act offense receive an extended prison term. An extended prison term must be imposed even if the prior conviction was for a Graves-Act offense that occurred after the offense for which the defendant is being sentenced. State v. Hawks, 114 N.J. 359, 554 A.2d 1330 (1989). The Legislature did not intend a lighter sentence for defendants whose previous conviction, though on appeal at the time of sentencing, is affirmed after sentence. The relevant portion of N.J.S.A 2C:43-6c provides:
A person who has been convicted of an offense enumerated by this subsection and who used or possessed a firearm during its commission, attempted commission or flight therefrom and who has been previously convicted of an offense involving the use or possession of a firearm as defined in 2C:44-3d., shall be sentenced by the court to an extended term as authorized by 2C:43-7c., notwithstanding that extended terms are ordinarily discretionary with the court.
However, N.J.SA 2C:44-4b provides:
An adjudication by a court of competent jurisdiction that the defendant committed a crime constitutes a prior conviction, although sentence or the execution thereof was suspended, provided that the time to appeal has expired and that the defendant was not pardoned on the ground of innocence. [Emphasis added.]
Although the emphasized portion of N.J.S.A 2C:44-4b provides in effect that an appeal of a prior Graves-Act conviction forestalls it’s consideration at the time of a Graves-Act sentencing, the defen*160dant is no less deserving of the mandated extended term if the prior conviction is affirmed. Were it otherwise, a person such as defendant could escape an extended prison term, mandated by statute, simply by filing an appeal of the prior Graves-Act conviction.
Recognizing the Legislature’s intent to impose an extended prison term on all Graves-Act second offenders regardless of whether at the time of sentencing the prior conviction is on appeal, leads to one of two conclusions. Either the sentencing judge can ignore the fact that the prior conviction is on appeal and impose an extended prison term subject to its being reduced if the prior conviction is reversed, or acknowledge that the prior conviction is on appeal and impose an ordinary prison term subject to its being increased if the prior conviction is affirmed.
In view of the directive in N.J.S.A 2C:44-4b that a conviction is not to be considered “prior” before “the time to appeal has expired,” we conclude that sentencing judges must follow the latter course. That is, where a prior Graves-Act conviction is on appeal at the time of sentencing for a second Graves-Act offense, the judge must impose an ordinary prison term. After the prior conviction has been affirmed, the State is entitled to have the sentence raised to an extended prison term because upon the affirmance, the sentence to an ordinary prison term becomes illegal. An illegal sentence may be corrected at any time, even by increasing the term. R. 3:22-2(c). State v. Kirk, 243 N.J.Super. 636, 581 A.2d 115 (App.Div.1990).
Our concurring colleague finds no basis in the Code for increasing a sentence without ignoring the language of N.J.S.A 2C:44-4b. We first “ignored” the statute in Mangrella, supra, when we stated that a sentencing judge may not consider a prior conviction that is on appeal even though the statute literally permits its consideration once “the time to appeal has expired.” We agree that it is certainly reasonable to infer that the Legislature intended to exclude from consideration a prior conviction while it is on appeal and not merely during the 45-day period within which an appeal may be taken.
*161It is just as reasonable to extend the inference and infer further that though it intended to exclude the prior conviction from being considered at sentencing during its appeal, the Legislature also intended that the prior conviction be considered at a resentencing after it has been affirmed. We rely on the Legislature’s clear mandate, unmistakable to defendants, that in all cases an extended term be imposed for a second Graves-Act offense.
Affirmed.