
34 Cal.App.3d 360 (1973)
109 Cal. Rptr. 193
THE PEOPLE, Plaintiff and Appellant,
v.
DAVID ANGELO AYALA, Defendant and Respondent.
Docket No. 23128.
Court of Appeals of California, Second District, Division Two.
September 26, 1973.
*362 COUNSEL
Joseph P. Busch, District Attorney, Harry B. Sondheim and Donald J. Kaplan, Deputy District Attorneys, for Plaintiff and Appellant.
Richard S. Buckley, Public Defender, Harold E. Shabo, Henry Bastien and Ronald B. Davey, Deputy Public Defenders, for Defendant and Respondent.
OPINION
FLEMING, J.
The People appeal an order of the superior court which set aside an information charging David Ayala with sale of heroin.
On 30 May 1972 Ayala sold a powdery substance purporting to be heroin to an undercover agent of the Pomona Police Department. A preliminary chemical analysis by a Pomona narcotics officer indicated the substance contained no opiates, and a felony complaint was filed against Ayala charging him with sale of a substance falsely represented to be a narcotic.[1] Following a preliminary hearing the magistrate ordered Ayala to stand trial but reduced the charge to a misdemeanor.[2] Subsequently, a sheriff's laboratory criminalist analyzed the powdery substance and concluded that it did contain heroin. The municipal court granted the prosecution's *363 motion to dismiss the charge for lack of proof, and Ayala was released after spending 64 days in custody on the charge. The prosecution filed a new felony complaint charging Ayala with sale of heroin[3] in the 30 May 1972 transaction with the informer, but the complaint was dismissed when the criminalist failed to appear at the preliminary hearing. The prosecution refiled the complaint charging sale of heroin, and after another preliminary hearing Ayala was ordered to stand trial on that felony charge. The superior court then granted Ayala's motion to set aside the information.
The question is whether prosecution on the second information charging sale of heroin will subject Ayala to the threat of double punishment or to needless multiple prosecution.
(1) Penal Code section 654 provides that an act which is made punishable in different ways by different criminal provisions may be punished under only one of those provisions. Ayala contends he is subject to double punishment in this case. He reasons: the 64 days he spent in custody on the charge of sale of a substance falsely represented to be a narcotic, a charge the evidence does not support, cannot be credited on his sentence on a conviction for sale of heroin; if he had been properly charged with sale of heroin in the first complaint he would be entitled to credit for the 64 days on his sentence should he be convicted on that charge; he therefore has already been irremediably punished on a charge of sale of substance falsely represented to be a narcotic, and cannot be punished under another criminal provision for the same sale of a powdery substance.
This logic fails for the invalidity of its basic premise. Ayala will be entitled to credit on his sentence for a conviction for sale of heroin for time spent in custody on the charge of sale of a substance falsely represented to be a narcotic. Penal Code sections 2900.5 and 2900.6, which provide for credit on sentence for time already spent in custody, state that credit shall be given "where the custody to be credited is attributable to charges arising from the same criminal act or acts for which the defendant has been convicted." Clearly the charge of sale of a substance falsely represented to be a narcotic arises from the same criminal act from which arises the charge of sale of heroin.
(2) Penal Code section 654 also provides that "an acquittal or conviction and sentence" under any criminal provision bars a prosecution for the same act under any other criminal provision. Ayala contends that he has already been prosecuted under former Health and Safety Code section *364 11503 for the act of selling a powdery substance, that the prosecution terminated in his favor with a dismissal, and therefore he may not be prosecuted under former Health and Safety Code section 11501 for the same act of selling a powdery substance.
The logic of this contention also fails. Penal Code section 654 requires "an acquittal or conviction and sentence." Ayala was not convicted and sentenced on the charge of sale of a substance falsely represented to be a narcotic, and dismissal of that charge before trial on motion of the prosecution is not equivalent to an acquittal. (Vizcarra v. Municipal Court, 27 Cal. App.3d 916, 919-920 [104 Cal. Rptr. 177]; see also People v. Hrjak, 85 Cal. App. 301, 303-304 [259 P. 353]; People v. Uhlemann, 9 Cal.3d 662, 666 [108 Cal. Rptr. 657, 511 P.2d 609].)
In Kellett v. Superior Court, 63 Cal.2d 822, 827 [48 Cal. Rptr. 366, 409 P.2d 206], the Supreme Court held that when the prosecution is or should be aware of more than one offense in which the same act or course of conduct plays a significant part, all such offenses must be prosecuted in a single proceeding in order to avoid needless harassment and the waste of public funds. Neither the letter nor the spirit of Kellett has been violated here. The prosecution reasonably relied on the results of a chemical analysis performed by a police narcotics officer in determining what charge to file against Ayala. When subsequent investigation revealed that a different and more serious charge was appropriate, the prosecution moved promptly to drop the first charge and file another. (Hampton v. Municipal Court, 242 Cal. App.2d 689 [51 Cal. Rptr. 760].) "This is not the case of a prosecutor harassing a defendant with multiple prosecutions for closely related offenses because of dissatisfaction with the punishment previously meted out or because of previous failure to convict." (People v. Eckley, 33 Cal. App.3d 91, 98 [108 Cal. Rptr. 52].)
Ayala was in no way prejudiced by the fact that the prosecution chose to dismiss the first charge before filing the second, rather than to join charges and then dismiss the first. (Vizcarra v. Municipal Court, supra, 27 Cal. App.3d 916, 920-921.) Penal Code section 1387, which provides that certain orders of dismissal are a bar to another prosecution for the same offense if the offense is a misdemeanor, has no application here because on the second filing Ayala was not charged with the same offense and on the second and third filings he was charged with a felony.
(3) In setting aside the information, the superior court opined that the prosecution had subverted the power of the magistrate by filing a second felony complaint after the magistrate had reduced the charge to a misdemeanor on the first complaint. (See Esteybar v. Municipal Court, 5 Cal. *365 3d 119 [95 Cal. Rptr. 524, 485 P.2d 1140].) A "separation of powers" argument does not fit the circumstances of this case, however. New evidence dramatically altered the nature of the case, the relevant criminal statutes, and the applicable penalties. The magistrate's first determination was made on the assumption of incorrect facts, and the prosecution was entitled to another determination in the light of the correct facts.
In adopting Penal Code section 17, subdivision (b)(5),[4] the Legislature "had in view the unburdening of the superior courts from cases that were likely to result in no more than misdemeanor penalties, the consequent more expeditious handling of such cases, the encouragement of guilty pleas by defendants who could know in advance that no penalty could be imposed more severe than a jail sentence or a fine, and the consequent saving of time to municipal courts by the elimination of some preliminary hearings." (Henry v. Department of Motor Vehicles, 25 Cal. App.3d 649, 653 [102 Cal. Rptr. 36].) None of these purposes would be served by dismissing the charge here.
The order setting aside the information is reversed.
Roth, P.J., and Compton, J., concurred.
NOTES
[1]  Former Health and Safety Code section 11503 (now contained in Health & Saf. Code, § 11355) punishable by imprisonment in state prison or county jail.
[2]  Penal Code section 17, subdivision (b): "When a crime is punishable, in the discretion of the court, by imprisonment in the state prison or by fine or imprisonment in the county jail, it is a misdemeanor for all purposes under the following circumstances: ... (5) When, at or before the preliminary examination and with the consent of the prosecuting attorney and the defendant, the magistrate determines that the offense is a misdemeanor, in which event the case shall proceed as if the defendant had been arraigned on a misdemeanor complaint."
[3]  Former Health and Safety Code section 11501 (now contained in Health & Saf. Code, § 11352), punishable only by imprisonment in state prison.
[4]  See footnote 2.
