OPINION OF THE COURT
Richard M. Weinberg, J.Defendant was indicted for the crimes of criminal sale of a controlled substance in the fifth degree (Penal Law § 220.31) and criminal possession of a controlled substance in the seventh degree (Penal Law § 220.03). His application for judicial diversion under CPL 216.05 was granted on November 16, 2010 and the case was adjourned for plea and placement. On November 30, 2010, defendant pleaded guilty to the top count of the indictment, signed a detailed written plea agreement, sentence was deferred, and defendant was placed in treatment. Defendant successfully completed his treatment mandate. Pursuant to the terms of the written plea agreement, defendant was allowed to withdraw his guilty plea and the indictment was dismissed on December 20, 2011.
On March 15, 2012, defendant filed the instant motion to have the records of his criminal action conditionally sealed pursuant to CPL 160.58. The People opposed the motion on the basis that the court is without authority to conditionally seal pursuant to CPL 160.58 because there exists neither a conviction nor a sentence in this case.
Chapter 56 of the Laws of 2009 created a Judicial Diversion Program (CPL article 216) for certain felony offenders who have a history of alcohol or substance abuse or dependence and where that abuse or dependence is a contributing factor to a de*401fendant’s criminal behavior. If institutional confinement is not necessary for the protection of the public and a defendant’s abuse or dependance may be effectively addressed through treatment, the court may defer sentencing and place the defendant in treatment through the Judicial Diversion Program. Upon successful completion of the Judicial Diversion Program, CPL 216.05 allows, among other outcomes, the withdrawal of defendant’s plea and the entry of a plea to a misdemeanor and the imposition of a sentence upon that plea. The statute also allows the withdrawal of defendant’s guilty plea and the dismissal of the indictment. If defendant does not successfully complete the Judicial Diversion Program, the court then sentences the defendant in accordance with the terms of the plea agreement. Accordingly, it is clear from the provisions of CPL 216.05 that the entire framework is based upon the deferral of sentencing by the court. In those cases where successful completion results in dismissal, no sentence is ever imposed. (See CPL 216.05 [9] [c], [e].)
Chapter 56 of the Laws of 2009 also created a new provision for the conditional sealing of the record of a defendant who successfully completes a Judicial Diversion Program (CPL 160.58). It also provides that the defendant could have up to three eligible prior misdemeanor convictions conditionally sealed. However, as drafted, this provision only applies to those defendants who, despite having successfully completed a Judicial Diversion Program, still have a conviction stemming from the underlying case and have completed the sentence imposed on that conviction. Where, as in this case, the defendant has been allowed to withdraw his plea and the case has been dismissed without sentence ever having been imposed, the conditional sealing provisions of CPL 160.58, literally, do not apply. (But cf. People v Smith, Sup Ct, NY County, Aug. 8, 2011, Padro, J., indictment No. 0234/09 [holding that a drug diversion mandate is the equivalent of a conditional sentence which entitles defendant to sealing under CPL 160.58].) The only option for the successful Judicial Diversion Program participant who has had his case dismissed is to petition for sealing under the provisions of CPL 160.50. This deprives that defendant of the opportunity of having up to three prior eligible misdemeanor convictions sealed. It also deprives the People of the advantages of a CPL 160.58 conditional sealing as opposed to the more rigorous restrictions the People face under a CPL 160.50 sealing. This anomaly should be addressed by the Legislature.
*402The detailed written plea agreement signed by the defendant at the time he entered his plea contains 14 separate provisions to which the defendant and the Diversion Court Judge agreed. Paragraph 7 provided that, if the defendant successfully completes MDC, the court will allow the defendant to withdraw his guilty plea and dismiss the charges. Paragraph 8 provided that, upon successful completion of the MDC program, the court will consider sealing the records of this criminal action and up to three prior misdemeanor convictions of offenses under Penal Law articles 220 or 221, pursuant to CPL 160.58 or not seal the records pertaining to this criminal action pursuant to CPL 160.50.
When this agreement was entered into, both parties understood that, upon successful completion of the Judicial Diversion Program, the court would consider sealing the records of this criminal action. This promise concerning sealing was one of several promises which induced the defendant to sign the plea agreement. At that time, both the court and the defendant were under the mistaken impression that the defendant would be eligible for conditional sealing under CPL 160.58, thereby obviating any need for sealing under CPL 160.50. Were the court to strictly adhere to the language of the plea agreement, the defendant would be deemed to have given up any right to having his record sealed — hardly a knowing, voluntary and intelligent waiver. When determining a defendant’s rights under a plea agreement, the court must be guided by the principle of essential fairness rather than strict contract law. (People v McConnell, 49 NY2d 340 [1980].) Where the parties to an agreement were operating under a mistaken impression, it is the obligation of a court to effectuate the purpose and intent of the plea agreement. (People v Labode, 280 AD2d 400 [2001], lv denied 96 NY2d 831 [2001]; People v Alvarez, 294 AD 2d 219 [2002].)
Under the circumstances of this case — as pointed out by the People — the court cannot legally fulfill its promise to consider sealing under CPL 160.58. Therefore, in order to effectuate the purpose and intent of the plea agreement, essential fairness leaves the court with no option except to consider sealing under CPL 160.50.
CPL 160.50 mandates the sealing of the record of any criminal action or proceeding which has terminated favorably unless the interest of justice requires otherwise. The defendant in this case successfully completed the Diversion Court Program, and, *403consistent with the plea agreement, his plea was withdrawn and the indictment against him was dismissed. To view this result as a CPL 160.50 favorable termination is consistent with the policies underlying CPL 160.50 and is consistent with the interests of justice. Defendant is 36 years old. This was his first and only arrest. Defendant is gainfully employed as an advertising account manager at a major firm, a position he held before his arrest and which he continued to hold throughout his course of treatment. Defendant has no history of violence and does not appear to be a threat to public safety. Since the criminal action against this defendant has terminated favorably and there exist no countervailing interest of justice considerations, the record of this proceeding is hereby sealed pursuant to CPL 160.50.