Petitioner Richard Frederick Krieger, confined by the Director of Corrections at the California Men’s Colony, East Facility, Los Padres, San Luis Obispo County, for an indeterminate period as a mentally disordered sex offender filed this petition for a writ of habeas .corpus upon the ground that there was no valid underlying criminal conviction at the time he was recertified by the Municipal Court of the Los Angeles Judicial District to the Superior Court of Los Angeles County under section 5518 of the Welfare and Institutions Code on September 30,1966. We conclude that we are compelled to grant the writ and order petitioner released from custody.
On September 15, 1965, petitioner pleaded guilty to a violation of section 2141 of the Business and Professions Code (practicing medicine without a license) in the Municipal Court of the Los Angeles Judicial District.
On October, 6, 1965, the municipal court certified petitioner to the Superior Court of Los Angeles County as a possible mentally disordered sex offender (hereafter “a MDSO”). As a result of proceedings pursuant to section 5512 of the Welfare and Institutions Code, petitioner was committed to the Atascadero State Hospital for an indeterminate period as a MDSO, on March 17,1966.
On March 29. 1966, the municipal court, with a deputy city attorney present but in the absence of petitioner and his counsel, ordered: “On the Court’s Motion, the plea of Guilty is set aside and matter is dismissed in the interest of justice. Defendant has been committed to the Atascadero State Hospital for an indeterminate time. Bail ordered exonerated. ’ ’
Upon certification under section 5517 of the Welfare and Institutions Code that petitioner would not benefit from further treatment at the state hospital, but was still considered to be a danger to society, he was returned to the municipal court for proceedings pursuant to section 5518 of the Welfare and Institutions Code. On September 30, 1966, the municipal court, again with a deputy city attorney present but in the absence of defendant and his counsel, ordered: “The Order made on March 29, 1966 is ordered vacated and set aside—. nunc pro tunc as of said date. [ ]f ] Proceedings remain *888adjourned. [ [[ ] Defendant recertified to Department 95 of Superior Court re Sections 5512 and 5518 Welfare Institutions Code. [ [[ ] Recertification of Mentally Disordered Sex Offender issued.1 *’
On October 14, 1966, the superior court committed petitioner to the Department of Mental Hygiene for an indeterminate period as a MDSO.
On October 31, 1966, the municipal court again made an order similar to the order of March 29, 1966, and dismissed “this matter ’’ on its own motion.
On October 24, 1968, petitioner’s motion for a hearing under section 5519 of the Welfare and Institutions Code was denied by the superior court.
On December 23, 1968, petitioner caused his petition for a writ of habeas corpus to be filed with this court. We issued an order to show cause why the writ should not be issued. To the return to the order to show cause, the People attached an affidavit of the municipal court judge, who made the orders of March 29, 1966, September 30, 1966, and October 31, 1966, which affidavit stated in part :
“The Court,’s purpose in dismissing [on March 29, 1966] was grounded on the fact that he [petitioner] was committed to the Department of Mental Hygiene for an indeterminate period and had already spent more than 90 days at the hospital. Consequently the Court felt that such was more punishment than the Court would impose for a violation of 2141 Business and Professions Code.
“However, on September 30, 1966, it was discovered that the defendant had to be returned to the Municipal Court for recertification to the Superior Court in accordance with sections 5512 and 5518 Welfare and Institutions Code. Therefore, the Court vacated its order of March 29, 1966 and recertified the defendant.
“It would be most unfortunate if the Court’s inadvertent error111 would cause this individual to be returned to society because he is a definite menace. Rest assured that the Court by its action on March 29, 1966 did not intend to return the defendant to society. ”
*889Petitioner moved to strike this affidavit from the return. The motion is denied. The motion is ambiguous; it asks that the affidavit be stricken for one purpose, but to be left standing for another limited purpose. “ ‘A motion to strike must be precise, definite, and certain. It must be directed with precision to the matter sought to be stricken. . . .’ ” (County of Los Angeles v. Hoe (1955) 138 Cal.App. 2d 74, 80 [291 P.2d 98]; accord People ex rel. Dept. of Public Works v. Alexander (1963) 212 Cal.App.2d 84, 98 [27 Cal.Rptr. 720].) If any part of the evidence is admissible, a general motion to strike the whole will be denied. (Rose v. State of Cal. (1942) 19 Cal.2d 713, 742 [123 P.2d 505]; see 48 Cal.Jur.2d, Trial, § 125 p. 168, and § 127 p. 170.)
The precise function of affidavits attached to a return or response to an order to show cause in a habeas corpus proceeding does not appear to have been spelled out by California cases. It has been accepted practice, however, that an affidavit may be attached to such a response or return.2 (See, e.g., In re Newbern (1960) 53 Cal.2d 786, 791 [3 Cal.Rptr. 364, 350 P.2d 116]; In re Atchley (1957) 48 Cal.2d 408, 409 [310 P.2d 15]; In re Norman (1961) 198 Cal.App.2d 105, 106-107 [17 Cal.Rptr. 772].) Affidavits of judges and court clerks as to a custom or procedural practice followed in their courts have been considered for the purpose of explaining or filling gaps in the official records. (In re Luce (1966) 64 Cal.2d 11, 13-14 [48 Cal.Rptr. 694, 409 P.2d 918]; In re Tucker (1966) 64 Cal.2d 15, 17-18 [48 Cal.Rptr. 697, 409 P.2d 921]; In re Johnson (1965) 62 Cal.2d 325, 330-331 [42 Cal.Rptr. 228, 398 P.2d 420]; In re Connor (1940) 16 Cal.2d 701, 707 [108 P.2d 10].) However, insofar as affidavits purport to set forth erroneous opinions, conclusions, irrelevant or immaterial matter, they are properly disregarded. (In re Connor, supra, at pp. 712-713.) The improper portions of the affidavit before us are being disregarded.
In Wright v. Dickson (9th Cir. 1964) 336 F.2d 878, cert. denied, 386 U.S. 1012 [18 L.Ed.2d 444, 87 S.Ct. 1360], the court explained on page 881: “It is not the purpose of the show cause proceeding to resolve disputed issues of fact, but only to determine whether such issues exist.” And on page *890882, it is further explicated: “The only-proper function of affidavits filed in a show cause proceeding is to bring to the court’s attention facts which may be undisputed, and to put in issue those which are in dispute. 1 [I] ssues of fact presented in habeas corpus proceedings may not be established by ex parte affidavits. ’ Jones v. Cunningham, 313 F.2d 347, 349 n. 4 (4th Cir. 1963), and cases cited. Denials of a petitioner’s allegations in an affidavit filed with a response to an order to show cause ‘only serve to make the issues which must be resolved by evidence taken in the usual way. They can have no other office. . . .’ Walker v. Johnston, 312 U.S. 275, 287, 61 S.Ct. 574, 579 (1941).” (See also: Witkin, Cal. Criminal Procedure (1963) p. 788.)
We agree with the municipal court judge that release of the petitioner may not be in the immediate best interests of society, but in light of In re Bevill (1968) 68 Cal.2d 854 [69 Cal.Rptr. 599, 442 P.2d 679] and section 1387 of the Penal Code, denial of the writ would violate due process of law guaranteed by the Fourteenth Amendment of the federal Constitution and article I, section 13, of the state Constitution.
In re Bevill, supra, held, inter alia (p. 858): (1) “Habeas corpus is appropriate to challenge the validity of a person’s commitment or continued confinement as a mentally disordered sex offender,'’ and (2) a commitment as a MDSO is invalid unless bottomed on a valid criminal conviction.
Section 1387 of the Penal Code provides: “An order for the dismissal of the action, made as provided in this chapter, is a bar to any other prosecution for the same offense if it is a misdemeanor. . . (Cf. People v. Ring (1937) 26 Cal.App. 2d Supp. 768, 770 [70 P.2d 281].) Section 1387 applies to dismissals under section 1385 of the Penal Code. (People v. Aiken (1951) 108 Cal.App.2d 343, 345 [238 P.2d 1019].) The March 29, 1966, order of dismissal in the interests of justice upon the municipal court’s own motion was a final disposition made pursuant to section 1385 of the Penal Code (Donati v. Righetti (1908) 9 Cal.App. 45, 49 [97 P. 1128]), and moreover one made after jeopardy had attached by virtue of petitioner’s plea of guilty accepted and entered in the minutes (People v. Mims (1955) 136 Cal.App.2d 828, 832 [289 P.2d 539]). The fact that the order was made inadvertently does not derogate from constitutional jeopardy preventing further prosecution from attaching. (People v. Valenti (1957) 49 Cal. 2d 199, 209 [316 P.2d 633], disapproved on another point in People v. Sidener (1962) 58 Cal.2d 645, 647 [25 Cal.Rptr. *891697, 375 P.2d 641]; People v. Garcia (1931) 120 Cal.App. Supp. 767, 769 [7 P.2d 401].) The order of March 29, 1966, was therefore tantamount to an acquittal after setting aside the guilty plea. Having thus “acquitted” the petitioner, the municipal court’s subsequent order of September 30, 1966, purporting to reinstate criminal proceedings and recertifying petitioner to the superior court as a MDSO, was null and void.
The superior court order of October 14, 1966, under which petitioner was committed to the Department of Mental Hygiene for an indeterminate period as a MDSO was not premised therefore upon a valid criminal conviction. It is thus vulnerable to the holding of In re Bevill (1968) supra, 68 Cal.2d 854. Due process compels our granting the writ and ordering petitioner’s discharge from custody.
Motion to strike the affidavit of the municipal court judge from the return to the order to show cause is denied; the writ of habeas corpus is granted and petitioner ordered discharged from custody.
Kaus, P. J., and Stephens, J., concurred.
A petition for a rehearing was denied June 3, 1969, and respondent’s petition for a hearing by the Supreme Court was denied July 9, 1969.
We realize, of course, that the municipal court made its orders of March 29, 1966, and October 31, 1966, without the benefit of the guidance of In re Bevill, infra. The error may not be as egregious as it appears at first blush. (Wilson v. Blabon (9th Cir. 1967) 370 F.2d 997, vacated 393 U.S. 20 [21 L.Ed.2d 19, 89 S.Ct. 49], discussed and considered by the court in In re Bevill, 68 Cal.2d 854, 859 [69 Cal.Rptr. 599, 442 P.2d 679].) However, In re Stoneham (1965) 232 Cal.App.2d 337, 340-341 [42 Cal.Rptr. 741] was available for guidance.
This would appear to be consonant with the general understanding that an order to show cause is in effect a notice of motion (Chichester v. Chichester (1964) 228 Cal.App.2d 491, 497 [39 Cal.Rptr. 553]; Sturm v. Sturm (1955) 138 Cal.App.2d 25, 28 [291 P.2d 527]) and that affidavits may be used in conjunction with motions (Code Civ. Proc., § 2009; People v. Kirk (1952) 109 Cal.App.2d 203, 209 [240 P.2d 630]).