
2 Cal.App.3d 732 (1969)
82 Cal. Rptr. 859
THE PEOPLE, Plaintiff and Appellant,
v.
ARTHUR WRIGHT, Defendant and Respondent.
Docket No. 16586.
Court of Appeals of California, Second District, Division Two.
December 17, 1969.
*734 COUNSEL
Thomas C. Lynch, Attorney General, William E. James, Assistant Attorney General, Evelle J. Younger, District Attorney, Harry Wood and Donald J. Kaplan, Deputy District Attorneys, for Plaintiff and Appellant.
MacCabe, George, Fritz & Belger, Alvin B. Calof, James A. Bohan and John J. Reidy, Jr., for Defendant and Respondent.
OPINION
WRIGHT, J.
Defendant, Arthur Wright, was charged by information with possession of marijuana for sale in violation of section 11531 of the Health and Safety Code. Defendant's motion to dismiss the information pursuant to Penal Code section 995 was granted. This appeal is by the People in accordance with Penal Code section 1238, subdivision 1.

Statement of Facts
Because of the limited issue which is before this court, only such facts as are necessary to a determination thereof will be set forth in this opinion.
Charles Ham was hired by the Pasadena Police Department to work as an undercover agent in a narcotic "buy" program. On the afternoon of June 12, 1968, Officer Ham went to defendant's apartment to attempt to purchase marijuana or other drugs. Later that evening, Ham purchased a quantity of marijuana from defendant for five dollars.
The complaint against defendant was filed in mid-November 1968, and defendant was arrested shortly thereafter. Officer Roberts of the Pasadena Police Department testified at the preliminary hearing that defendant was not arrested sooner because Officer Ham was working on a number of other cases as an undercover agent, and the police department did not want Ham's identity disclosed until they were ready to make all the arrests connected with the "buy" program.
The preliminary hearing was held on December 13, 1968, and the magistrate held defendant to answer on the charge of possession of marijuana. Defendant's motion to dismiss the information pursuant to section 995 of the Penal Code was heard on January 22, 1969. The motion was granted on the sole ground that there was an unreasonable delay between the time of the alleged offense and the time of defendant's arrest.


*735 Issue On Appeal

The only issue on appeal is whether defendant's commitment by the magistrate was unlawful in that defendant was denied his right to a speedy trial because of the five-month delay between the time of the alleged offense and the time of his arrest.

Discussion
At the outset, there is a point which has not been argued by counsel for either side and upon which we must make a determination. That point is whether the delay in defendant's arrest was a proper ground for the order setting aside the information under section 995. Section 995 is limited in scope and provides in relevant part that an information "must be set aside by the court" whenever it appears either "That before the filing thereof the defendant had not been legally committed by a magistrate," or "That the defendant had been committed without reasonable or probable cause." Since there was no question of reasonable or probable cause in this case, the only ground upon which the trial judge could have properly set aside the information was that the defendant "had not been legally committed by a magistrate."
The scope of the phrase "legally committed," as used in section 995, has frequently been interpreted by the courts. (See Jennings v. Superior Court, 66 Cal.2d 867, 874-875 [59 Cal. Rptr. 440, 428 P.2d 304], and cases cited therein.) (1) The rule which has evolved from these cases is that where evidentiary inquiry during the course of a preliminary examination establishes that the defendant has been deprived of a substantial right, the commitment is unlawful and the deprivation may be asserted through a motion to set aside the information under section 995. (McCullar v. Superior Court, 264 Cal. App.2d 1, 8 [70 Cal. Rptr. 21].) We will assume for the purpose of this appeal that had defendant been able to establish at the preliminary hearing that he was prejudiced by the delay in his arrest, there would have been a deprivation of a substantial right with the result that his commitment by the magistrate would have been unlawful. A motion under section 995 would be proper under such circumstances.
This brings us to the real issue in the case, namely, whether defendant was in fact denied his right to a speedy trial. The court below granted defendant's motion on the basis that the five-month delay was unreasonable as a matter of law.[1] We disagree with this conclusion. As stated in People v. Alvarado, 258 Cal. App.2d 756, 759 [66 Cal. Rptr. 41], "We know of no *736 requirement that an accused be arrested at any specific time between the commission of the offense and the expiration of the time provided by the statute of limitations as to that particular crime." (2) Whether the delay in defendant's arrest was unreasonable and prejudicial is a question of fact, and the lapse of a specific period of time will not in itself justify a finding that defendant was denied due process of law. (People v. Alvarado, supra.)
(3) In cases involving narcotic "buy" programs, there is no hard and fast rule establishing how much of a delay in defendant's arrest constitutes a denial of due process to him. Each case must be resolved by balancing the public interest and the rights of the defendant. (People v. Alvarado, 258 Cal. App.2d 756, 759 [66 Cal. Rptr. 41].) The necessity of using undercover agents to detect violations of the narcotic laws is obvious. "[I]t is within the realm of common knowledge and common sense that uniformed or otherwise known policemen are unable to penetrate the sub rosa world of the narcotics peddler. Extensive, time-consuming investigations by undercover operatives, who daily risk their lives, are required to get to the retail and wholesale sources of illicit narcotics." (People v. Gilmore, 239 Cal. App.2d 125, 130 [48 Cal. Rptr. 449], quoting from Powell v. United States, 352 F.2d 705, 708 [122 App.D.C. 229].) It is equally obvious that the effectiveness of such an agent does not survive the time it becomes known that he is a policeman. The public thus has a substantial interest in keeping the officer's identity secret for a reasonable period of time while he continues his investigations. This public interest is a legitimate reason for delaying the arrest of an individual wrongdoer. (People v. Alvarado, supra, at p. 760.) The courts have recognized this fact, and the cases are legion which have upheld the use of narcotic "buy" programs as acceptable police practice. (E.g., People v. Alvarado, supra; People v. Gilmore, supra; People v. Wilson, 239 Cal. App.2d 358 [48 Cal. Rptr. 638]; People v. Crowder, 257 Cal. App.2d 564 [64 Cal. Rptr. 913].)
This does not mean, however, that the public interest must always prevail. The accused has substantial rights which must be protected, and the delay between the alleged offense and the time of arrest must not result in a deprivation of due process. Delaying the arrest of the accused may hinder his ability to recall or reconstruct his whereabouts at the time the alleged offense occurred. As stated by the dissent in Powell v. United States, 352 F.2d 705, 710 [122 App.D.C. 229], "The accused has no way of knowing, to say nothing of proving, where he was at the time and on the day the policeman says his diary shows he made a sale of narcotics to the policeman." An additional problem resulting from such delays is misidentification, where an undercover officer saw the accused only occasionally and then for brief periods of time. There is no doubt that under certain *737 circumstances the delay in filing the accusation makes it difficult or impossible for an accused to adequately prepare his defense.
But the fact that the question in this type of case must be resolved by balancing interests does not mean that there are no guidelines for a court to follow. We agree with the statement in Powell v. United States, 352 F.2d 705, 708 [122 App.D.C. 229], that "an accused must show two things in order to invoke an exercise of our supervisory power because of alleged basic `unfairness' [citation omitted] resulting from claimed delay in his arrest: that there was no legitimate reason for the delay, and that he was prejudiced by the delay."
(4) As previously pointed out, there was a legitimate reason for delaying defendant's arrest. Officer Ham's involvement as an undercover agent in the narcotic "buy" program required his identity to be kept secret while he contiued his investigations. Defendant has not shown that the delay was for any unlawful purpose, nor that it was for an unjustifiable period of time. More importantly, defendant has made no attempt, either at the preliminary hearing or before this court, to show that the delay was in any way prejudicial to him. Since the People have established a valid reason for delaying the arrest, and since defendant produced no evidence to show that he suffered prejudice thereby, the balance of interests must fall in favor of the People.
The order granting defendant's motion to set aside the information is reversed.
Herndon, Acting P.J., and Fleming, J., concurred.
NOTES
[1]  In granting the motion, the court below stated in part: "I don't see any necessity for waiting five months to bring one of these cases to a head, and I am going to grant the motion on that basis. You [the People] may take an appeal. I think it is unreasonable to put a defendant to a tremendous disadvantage to wait five months to charge him with an offense such as this."
