Appeal by the defendant from a judgment of the County Court, Westchester County (Colabella, J.), rendered November 20, 1985, convicting him of attempted criminal sale of a controlled substance in the third degree, upon his plea of guilty, and imposing sentence.
Ordered that the judgment is affirmed.
*773The issue with respect to whether an agency defense existed was raised and, therefore, preserved by the defendant’s statements at the time of the plea which alerted the court to the insufficiency of the guilty plea (see, People v Serrano, 15 NY2d 304, 309). When apprised of the existence of a possible agency defense, the court conducted an extensive inquiry to determine that the defendant was aware of and understood the elements of the crime to which he was pleading, including the possibility of an agency defense.
We find that the defendant’s plea was entered into knowingly, voluntarily and with understanding of the consequences (see, North Carolina v Alford, 400 US 25). There is no suggestion in the record that the plea was improvident or baseless, especially given the plea-bargaining agreement which avoided the risk of the defendant’s conviction, upon a trial, of the more serious crimes charged in the indictment (see, People v Nixon, 21 NY2d 338, 350, cert denied sub nom. Robinson v New York, 393 US 1067; People v Langhorn, 119 AD2d 844, lv denied 68 NY2d 758). Mangano, J. P., Kunzeman, Rubin, Kooper and Harwood, JJ., concur.