
108 Cal.App.2d 431 (1951)
THE PEOPLE, Respondent,
v.
GEORGE BRECEDA LAVANDERA, Appellant.
Crim. No. 4708. 
California Court of Appeals. Second Dist., Div. Three.  
Dec. 27, 1951.
 Gloria Farquar for Appellant.
 Edmund G. Brown, Attorney General, and Stanford D. Herlick, Deputy Attorney General, for Respondent.
 SHINN, P. J.
 George Lavandera was convicted of petty theft in the Justice Court of San Jose Township, Los Angeles County, and sentenced to the county jail. On his 18th birthday, he escaped from the Los Angeles County Wayside Honor Rancho, a facility of the county jail. He was later apprehended, tried, convicted and sentenced to San Quentin for the felony of escape. He appeals from the judgment and an order denying his motion for a new trial. There is no dispute as to the facts, the sole issue being the legality of the confinement from which defendant liberated himself. It is not questioned by the People that defendant was under 18 years at the time the offense of petty theft occurred. Since the justice court did not refer his case to the juvenile court, defendant contends that his conviction and confinement were void and the escape lawful. No appeal was taken from the conviction of petty theft. The fact the defendant was under 18 at the time of the offense was first brought out in his trial for escape.
 In a brief which evidences great industry and extensive research upon the part of his counsel, defendant relies on what he claims to be a clear and absolute legislative command that no court has jurisdiction to try a person under 18 without *433 first referring the matter to the juvenile court. This contention is based on section 825 of the Welfare and Institutions Code which reads: "No court shall have jurisdiction to try the case of any person under the age of eighteen years at the time of the alleged commission of a public offense or crime unless the matter has first been submitted to the juvenile court by petition as provided in Article 7 of this chapter, or by certificate of any other court as provided in this article, and said juvenile court has made an order therein directing that such person be prosecuted under the general law." A reading of this section alone might lead to a conclusion that even though the trial court after taking evidence had determined a defendant to be 18 or over there could be no valid trial without a referral to the juvenile court if defendant was actually under 18. [1] It is necessary, however, to look beyond section 825 and read it with the following section as an entire enactment. Section 826 provides that whenever it is suggested or appears to the trial judge that the defendant was under 18, "he shall examine into the age of such person, and if, from such examination, it appears to his satisfaction that such person was at the date the offense is alleged to have been committed under the age of eighteen years, he shall forthwith certify [the matter] to the juvenile court. ..." Section 826 governs in the matter of referral to the juvenile court; section 825 to cases that are or should have been referred. The court having jurisdiction over the crime and person may proceed unless after the court's investigation it appears to the satisfaction of the trial judge that the defendant was under 18 at the date of the offense. The fact as to age must at this preliminary stage of the proceeding be determined in order that the case may proceed in accordance with the finding of the trial judge. If the finding is in error jurisdiction is not for that reason defeated.
 [2] Where jurisdiction depends upon a factual condition, the existence of which must be found by the court before further proceedings are had, and in regular manner it is found that the condition does exist, the court has authority to proceed, and an erroneous determination, even if reversible on appeal, is not subject to collateral attack. (Matter of Maginnis, 162 Cal. 200, 206 [121 P. 723]; Ex parte Williams, 87 Cal. 78 [24 P. 602, 25 P. 248], 49 C.J.S., p. 849.) [3a] If an accused minor has been accorded his procedural rights under section 826 and is tried, convicted and committed without certification to the juvenile court, the fact that he may *434 have been under the age of 18 years at the time his offense was committed does not render his confinement unlawful. (Cf. People v. Oxnam, 170 Cal. 211 [149 P. 165]; In re Bastiani, 81 Cal.App. 294 [253 P. 951].) The preliminary inquiry as to the age of a minor is not unlike an inquiry as to the present sanity of an accused. [4] Although section 1368 of the Penal Code gives an accused a right to a trial of his present sanity it is conditioned upon the existence in the mind of the trial judge of a doubt as to the sanity of the defendant. (People v. Perry, 14 Cal.2d 387, 399 [94 P.2d 559, 124 A.L.R. 1123]; People v. Lindley, 26 Cal.2d 780, 789 [161 P.2d 227].) [3b] In the case of a minor referral is not required unless it appears to the satisfaction of the judge that the accused is under 18 years of age.
 Here it is shown that in the justice court defendant represented to the court that he was 19 years of age. His statement was taken as true and therefore the judge was not satisfied that he was under 18. Reference to the juvenile court under section 826 would have been unjustified. Defendant was properly tried in the justice court. His confinement was legal and his escape from custody constituted the offense of which he was convicted.
 The judgment and order are affirmed.
 Wood (Parker), J., and Vallee, J., concurred.
