On May 19,1959, the defendant was arrested and arraigned in the former Magistrate’s Court of the City of New York upon a complaint charging that between September, 1956 *312and May, 1959 he stole merchandise of the value of $624 from the warehouse of his employer. Defendant waived examination to await the action of the Grand Jury, and was admitted to bail.
The proceeding remained in suspense until April 12, 1961, when the defendant moved in the County Court to dismiss the complaint for failure to prosecute (Code Grim. Pro., § 667). At the District Attorney’s request, the motion was adjourned to April 26, 1961; and, at the request of the defendant’s attorney, it was again adjourned to May 10, 1961. In the meantime, on May 1, 1961, the defendant was indicted by the Grand Jury, charged with forgery in the third degree in 12 counts, and with grand larceny in the second degree in 2 counts. On May 17, 1961, the defendant’s motion to dismiss the complaint for failure to prosecute was denied. The denial was placed on the ground that the return of the indictment had rendered inapplicable the provisions of section 667 of the Code of Criminal Procedure.
On June 7, 1961 the defendant was arraigned upon the indictment ; he renewed his motion to dismiss for failure to prosecute ; and pleaded not guilty. On October 24,1961, the defendant withdrew such plea and thereupon pleaded guilty to attempted grand larceny in the second degree, to cover all counts in the indictment. In entering the guilty plea, defendant’s counsel made clear that the defendant did not waive any rights under the motions that he had previously made, and the court expressly stated that whatever rights he had were preserved. On March 30,1962 the defendant was given a suspended sentence and was placed on probation.
Section 667 of the Code of Criminal Procedure, upon which the defendant relies, provides: “ When a person has been held to answer for a crime, if an indictment be not found against him, at the next term of the court at which he is held, to answer, the court may on application of the defendant order the prosecution to be dismissed, unless good cause to the contrary be shown.” This section is a part of chapter VII of the Code of Criminal Procedure, which is headed: “ Dismissal of the action, before or after indictment, for want of prosecution or otherwise.” That chapter provides the means of enforcing the right of a defendant to a speedy trial (Code Grim. Pro., § 8, subd. 1; Civil Eights Law, § 12). So the Report of the Commissioners on Practice and Pleading stated in 1849 (Report of Commissioners on Practice and Pleading, p. 341; McKinney’s Cons. Laws of N". Y., Book 66, Part 2, Code Crim. Pro. [1958 ed.], p. 687): “ This Chapter is intended to remedy, what the Commissioners deem defects in the existing practice, productive not only of great inconvenience, but of flagrant injustice. When a defend*313ant is held to answer, or is indicted, there is now no mode of his compelling the prosecution to proceed to trial, or of his being relieved from the indictment.”
Section 668 of the Code of Criminal Procedure, which accords to the defendant the companion right to move to dismiss an indictment for want of prosecution, has been construed to impose the burden on the prosecution to establish “ good cause ” for its own delay (People v. Prosser, 309 N. Y. 353, 358). Precisely the same burden rests on the prosecution under section 667 of the Code of Criminal Procedure. In the light of the conditions which these statutes were designed to remedy, there is no difference between one held to await the action of the Grand Jury and one held under indictment. In both instances the statutes prevent prolonged imprisonment of the accused if he be held in jail; relieve the accused of anxiety and public suspicion while he awaits trial; and protect him from exposure to a trial after a delay which may result in the loss of the means of proving his defense (People v. Prosser, 309 N. Y. 353, 356, supra).
Though the court may exercise discretion in the determination of the application to dismiss for lack of prosecution (People v. Alfonso, 6 N Y 2d 225), such discretion must be exerted not arbitrarily, but upon a sound factual basis (cf. People v. Duchin, 16 A D 2d 483-485, affd. 12 N Y 2d 351). When this defendant first moved to dismiss the proceeding prior to indictment, a delay of nearly 23 months had elapsed since its inception. When the motion was heard nearly a month later, the District Attorney in his answering affidavit presented no reason for the delay. He claimed merely that the motion should be denied because some 10 days prior thereto an indictment had been found against the defendant.* Hence, there was no basis for the exercise of discretion to deny the motion, unless the intervening return of the indictment provided it.
At common law, because the failure to indict a person held to answer a charge before the Grand Jury did not discharge the offense, statutes were enacted in many States to secure a speedy trial. The purpose of such statutes was to safeguard a defendant from the abuses arising from the common-law rule (United States v. Cadarr, 197 U. S. 475, 478). The effect of such statutes *314depends on their language and on their underlying policy (United States v. Cadarr, supra; Ex Parte Bull, 42 Cal. 196; Newlin v. People, 221 Ill. 166; Ann., 50 A. L. R. 2d 943, 946). Although it has been broadly held in our State that a Grand Jury may indict regardless of any defects in the proceedings before the Magistrate (People ex rel. Hirschberg v. Close, 1 N Y 2d 258), we think that the policy of our statutes requires a consistent course where an unwarranted delay in prosecution occurs, whether the delay be encountered before or after indictment. The prejudice to the defendant flows from the lapse of time; and the form of the accusation does not overcome the prejudice suffered by him or change the elements of the right guaranteed to him. Though the Grand Jury may have jurisdiction to indict (People v. Stern, 3 N Y 2d 658), the defendant’s right to a speedy trial survives; and whether the indictment can withstand the challenge of a violation of that right depends on all the circumstances of the case, including the proceedings before the Magistrate prior to the indictment.
Clearly, the reindictment of an accused after dismissal of an indictment against him for lack of prosecution may itself be dismissed, where the total delay infringes the guarantee of a speedy trial (People v. Wilson, 8 N Y 2d 391). Likewise, a long and unjustified delay in imposing sentence may invalidate a conviction (People ex rel. Harty v. Fay, 10 N Y 2d 374). Here, the failure to indict for nearly two years contravened the right to a speedy trial to which the defendant was entitled (cf. People v. Piscitello, 7 N Y 2d 387; People v. Masselli, 11 A D 2d 722). To hold that ipso facto the subsequent finding of an indictment excused the prior delay and revitalized the prosecution would minify the purpose of the statutory scheme and destroy the defendant’s rights. Nor did the defendant’s plea of guilty to the indictment divest him of his rights (People v. Wilson, supra; People v. Chirieleison, 3 N Y 2d 170).
Hence, we conclude that the provisions of chapter VII of the Code of Criminal Procedure must be read together, and that the total effect of undue delay without adequate explanation commands dismissal of the indictment and the prosecution against the defendant (People v. Wilson, supra, pp. 395-396; cf. note, “The Right to a Speedy Criminal Trial,” 57 Col. L. Rev. 846, 848-849).
The judgment and order should be reversed on the law, the motion granted, the indictment and the complaint dismissed, and the defendant discharged. No questions of fact were considered,
In his brief upon the present appeal the District Attorney asserts that he argued before the court below that time was not of the essence, because of the mass of records which had to be analyzed prior to submission of the ease to the Grand Jury. Assuming that we may properly consider these facts, it must be observed that no circumstances were presented which supported the conclusion that the investigation required 23 months; and, of course, the indictment was returned 20 days after the defendant made his first motion to dismiss.