
    The People of the State of New York, Respondent, v Orlando Martinez, Appellant.
    [624 NYS2d 498]
   —Judgment unanimously modified on the law and as modified affirmed and matter remitted to Monroe County Court for further proceedings in accordance with the following Memorandum: The presentence investigation report indicates that, prior to commission of the subject crimes, defendant had been convicted of grand larceny in the fourth degree, a class E felony, and that defendant was a second felony offender. Under the circumstances, the People were required to file a second felony offender statement with the court prior to sentencing, and the court was required to sentence defendant as a second felony offender (see, CPL 400.21). The failure to comply with those statutory mandates renders the sentence invalid as a matter of law (see, People v Scarbrough, 66 NY2d 673, revg on dissent of Boomer, J., 105 AD2d 1107, 1107-1109). We reach the issue sua sponte because an unlawful sentence cannot stand (see, People v Palmeri, 186 AD2d 1075; People v Mohammed, 151 AD2d 1018, Iv denied 74 NY2d 815; People v Price, 140 AD2d 927, 928; People v Peale, 122 AD2d 353). Thus, we modify the judgment by vacating the sentence (see, CPL 470.15 [2] [c]), and we remit the matter to Monroe County Court so that defendant may withdraw his guilty plea and stand trial or be resentenced in compliance with CPL 400.21. Moreover, because the People’s consent to acceptance of the plea was conditioned upon consecutive sentencing and an aggregate minimum imprisonment term of 10 years, the court must entertain a motion by the People, should the People be so disposed, to vacate the plea if the court, on resentencing, is unable to fulfill that portion of its promise (see, People v Keiffer, 207 AD2d 1022). (Appeal from Judgment of Monroe County Court, Marks, J.—Criminal Possession Controlled Substance, 2nd Degree.) Present—Denman, P. J., Lawton, Wesley, Balio and Davis, JJ.  