
    The People of the State of New York, Respondent, v Daniel W. DePerno, Appellant.
    [937 NYS2d 765]
   McCarthy, J.

Defendant contends, and the People concede, that the sentences imposed were illegal. A defendant must be sentenced according to the law as it existed at the time that he or she committed the offense (see People v Sawinski, 246 AD2d 689, 692 [1998], lv denied 91 NY2d 930 [1998]). In 2007, the Legislature categorized rape in the second degree and criminal sexual act in the second degree as violent felony offenses and enacted the felony sex offender statute (see L 2007, ch 7, §§ 30, 32). Because defendant committed the crimes at issue here in 2006 — prior to the Legislature’s amendments to the relevant statutes — the prison sentences for these crimes had to be indeterminate terms, and postrelease supervision was not authorized (see People v Sapienza, 75 AD3d 768, 772-773 [2010]). We therefore vacate the illegal sentences that were imposed. As the agreed-upon sentences cannot legally be imposed, we remit to County Court for resentencing in accordance with the relevant statutes, with the opportunity for either party to withdraw from the plea agreement (see People v Cameron, 83 NY2d 838, 840 [1994]; People v Ryan, 83 AD3d 1128, 1130 [2011]).

Mercure, A.EJ., Rose, Spain and Malone Jr., JJ., concur. Ordered that the judgment is modified, on the law, by vacating the sentences imposed; matter remitted to the County Court of Cortland County for further proceedings not inconsistent with this Court’s decision; and, as so modified, affirmed.  