
17 Cal.App.3d 949 (1971)
95 Cal. Rptr. 270
THE PEOPLE, Plaintiff and Respondent,
v.
WILLIAM CLYDEAN BELL et al., Defendants and Appellants.
Docket No. 18066.
Court of Appeals of California, Second District, Division Two.
May 27, 1971.
*951 COUNSEL
Melvyn D. Sacks, under appointment by the Court of Appeal, for Defendants and Appellants.
Evelle J. Younger, Attorney General, William E. James, Assistant Attorney General, and Beverly K. Falk, Deputy Attorney General, for Plaintiff and Respondent.
OPINION
HERNDON, J. 

Statement of the Case
After separate nonjury trials defendants Bell and Jackson were convicted of the murder of William E. Hall. At the conclusion of each trial the judge presiding announced his determination that the murder had been committed in the course of robbery and was therefore murder of the first degree. Each defendant has appealed from the judgment declaring him guilty of murder of the first degree and sentencing him to state prison for the term prescribed by law.
Since the trial record in each case discloses evidence establishing the guilt of both appellants to a moral certainty, and since the sufficiency of *952 that evidence is unquestioned, it is unnecessary to recite the distressing details of the murder which both trial judges aptly described as brutal, vicious and coldblooded.
It is sufficient to state that on the night of the murder the victim, while en route to his place of employment, stopped his car and picked up the hitchhiking appellants who promptly proceeded to reward his act of generosity by robbing and killing him. Mr. Hall's death was caused by a gunshot wound in the head. The gun, held in the hand of Jackson, was fired from a distance of approximately 3 inches from Hall's head. Leaving their dying victim, appellants took his car and other of his possessions and fled from the scene. Both appellants were juveniles 16 years of age.
In each of these two cases the trial court found the defendant guilty of murder committed in the course of robbery and therefore necessarily guilty of murder of the first degree. Notwithstanding that life imprisonment is the only legally permissible sentence for first degree murder committed by a person under the age of 18 years, and notwithstanding the provisions of section 1731.5 of the Welfare and Institutions Code (quoted below), the trial judge in each case referred the defendant to the California Youth Authority for the declared purpose of ascertaining whether or not the authority would accept him.
In both cases the authority refused to accept the referred defendants on the basis of stated findings that they were not proper persons to be retained in view of their convictions of first degree murder and the provisions of section 1731.5. Appellants, having been rejected by the authority, were ordered returned to the trial court for sentencing pursuant to the provisions of section 1737.1 of the Welfare and Institutions Code. The defendants were returned and thereafter the judgments now under review were made and entered.
Sections 1731.5 and 1737.1 of the Welfare and Institutions Code, prior to 1969 amendments, provided in pertinent part as follows:
Section 1731.5: "After certification to the Governor as provided in this article a court may refer to the authority any person convicted of a public offense who comes within all of the following description:
"(a) Is found to be less than 21 years of age at the time of apprehension;
"(b) Is not sentenced to death, imprisonment for life, imprisonment for 90 days or less, or the payment of a fine, or after having been directed to pay a fine, defaults in the payment thereof, and is subject to imprisonment for more than 90 days under the judgment;
"(c) Is not granted probation.
*953 "If the authority believes that any person referred to it as provided in this section can be materially benefited by the procedure and discipline of the authority, and that proper and adequate facilities exist for the care of such person, it shall so certify to the court. The court shall thereupon commit said person to the authority."
Section 1737.1: "Whenever any person who has been charged with or convicted of a public offense and committed to the Authority appears to the Authority, either at the time of his presentation or after having become an inmate of any institution or facility subject to the jurisdiction of the Authority, to be an improper person to be retained in any such institution or facility, or to be so incorrigible or so incapable of reformaton under the discipline of the Authority as to render his retention detrimental to the interests of the Authority and the other persons committed thereto, the Authority may return him to the committing court. In the case of a person convicted of a public offense, said court may then commit him to a State prison or sentence him to a county jail as provided by law for punishment of the offense of which he was convicted...."
Appellants contend that orders of the respective trial judges committing them to the California Youth Authority operated to deprive the trial court of jurisdiction subsequently to sentence them to state prison after they had been returned by the authority to the committing court pursuant to section 1737.1 of the Welfare and Institutions Code.
We have concluded that appellants' contentions are invalid. The orders committing appellants to the Youth Authority, whether they be regarded as void or merely erroneous, were violative of statutory and decisional law. Since the authority acted in conformity with its statutory power in finding that appellants were improper persons to be retained in any institution or facility under its jurisdiction, they were lawfully and properly returned to the committing court pursuant to section 1737.1 and sentenced "as provided by law for punishment of the offense[s] of which [they were] convicted."

Relevant Procedural History in Jackson's Case
On March 12, 1969, at the conclusion of Jackson's trial, the trial judge announced his verdict that the victim of the homicide had been killed in the course of an armed robbery and that "the evidence points rather conclusively to the fact that the defendant Jackson... was the man that pulled the trigger. Under these circumstances, I will find the defendant guilty as charged of murder in the first degree." At the request of Jackson's *954 counsel, the court then stated that it would reserve its finding as to degree until the time of probation and sentence hearing.
On June 26, 1969, the trial court restated its finding that Jackson was guilty of felony murder and indicated its intention to refer him to the Youth Authority. The court at that time made no finding as to the degree of the murder but declared "Criminal proceedings are now suspended. The matter will be referred to the California Youth Authority to see if the defendant is acceptable for commitment." On July 10, 1969, the trial court made its formal order committing Jackson to the Youth Authority. Under date of October 23, 1969, the Youth Authority addressed a communication to the court stating in substance that the commitment to the authority was in error and that the defendant Jackson was not eligible for acceptance. On October 24, 1969, the trial court entered its order reciting the finding of the California Youth Authority that Jackson's prior commitment had been in error and directing that said defendant be returned to the court for resentencing. On November 17, 1969, the court entered its judgment reciting that Jackson had been found guilty of murder of the first degree and sentencing him to state prison.

Relevant Procedural History in the Bell Case
On September 2, 1969, at the conclusion of Bell's trial, the court stated: "The court finds that this killing was, beyond a reasonable doubt, one that took place in the course of a robbery.... Defendant will be found guilty of murder in the first degree." September 23, 1969 was the date set for the hearing on Bell's motion for a new trial and for probation and sentence. Following the hearing on the latter date the court caused the following minute order to be entered:
"Matter of motion of defendant for a new trial and probation and sentence comes on for hearing. Motion of defendant for a new trial denied. Proceedings suspended and the defendant is referred to the California Youth Authority to determine whether or not said California Youth Authority will accept the defendant. Proceedings continued to October 14, 1969, 9 a.m., for determination by the California Youth Authority with respect to the acceptance or rejection of the defendant. Remanded."
Approximately one week after the referral, the California Youth Authority addressed a communication to the court indicating that Bell would not be accepted by the authority for the reason that he had been convicted of first degree murder and was therefore unacceptable. Accordingly, on September 30, 1969, Bell was ordered returned to the trial court for sentencing. On October 14, 1969, after having found that "the defendants' *955 previous referral to the California Youth Authority was invalid," the court entered its judgment reciting that Bell had been found guilty of murder of the first degree and sentencing him to state prison.

Appellants Having Been Found Guilty Of Felony Murder And Being Then Under The Age of 18 Years, Life Imprisonment Was The Only Legally Permissible Sentence.
"All murder which is ... committed in the perpetration of, or attempt to perpetrate ... robbery ... is murder of the first degree." (Pen. Code, § 189.) Life imprisonment is the only lawful sentence that may be imposed upon any person for murder committed by such person before he had reached the age of 18 years. (Pen. Code, §§ 190 and 190.1.)
Section 12 of the Penal Code provides: "The several sections of this code which declare certain crimes to be punishable as therein mentioned, devolve a duty upon the court authorized to pass sentence, to determine and impose the punishment prescribed." (Italics added.) As our Supreme Court has stated, "Upon conviction it is the duty of the court to pass sentence on the defendant and impose the punishment prescribed." (In re Sandel, 64 Cal.2d 412, 415 [50 Cal. Rptr. 462, 412 P.2d 806]; see also People v. Morrow, 275 Cal. App.2d 507, 514-516 [80 Cal. Rptr. 75].) (1) In People v. Machado, 150 Cal. App.2d 190, 193-194 [309 P.2d 903], we restated the law as follows:
"Homicide committed in the perpetration of robbery is murder in the first degree regardless of whether the killing be wilful, deliberate and premeditated or even accidental (Pen. Code, § 189; People v. Sutton, 17 Cal. App.2d 561, 567 [62 P.2d 397]). (2, 3) A principal in a robbery resulting in a homicide may be found guilty of murder in the first degree notwithstanding that his codefendant fired the fatal shot (People v. Leon, 129 Cal. App.2d 676, 679 [277 P.2d 481]), and principals include those persons who advise or encourage the commission of a crime or who aid and abet in its commission. (Pen. Code, § 31; People v. Perkins, 37 Cal.2d 62, 64 [230 P.2d 353].)"
(4a, 5) The correctness of the actions of the trial judges in recognizing their errors in committing the ineligible defendants to the Youth Authority and in imposing the sentences mandated by the plain provisions of the Penal Code is indicated by the following restatement of the law in People v. Massengale, 10 Cal. App.3d 689, 693 [89 Cal. Rptr. 237]:
"When a court pronounces a sentence which is unauthorized by the Penal Code, that sentence must be vacated and a proper sentence imposed whenever the mistake is appropriately brought to the attention of the court. *956 (See In re Sandel, 64 Cal.2d 412 [50 Cal. Rptr. 462, 412 P.2d 806] (illegal concurrent sentence for escape corrected to run consecutively); In re Robinson, 142 Cal. App.2d 484, 486 [298 P.2d 656] (jail sentence for forcible rape vacated and prison sentence substituted).) (6) If a trial court refuses to correct an illegal sentence, the People may obtain relief in the appellate court by writ of mandate. (People v. Superior Court, 135 Cal. App. 562 [27 P.2d 670]; People v. Superior Court, 116 Cal. App. 412 [2 P.2d 843].) (7) When the mistake is discovered while the defendant's appeal is pending, the appellate court should affirm the conviction and remand the case for a proper sentence. (People v. Phillips, 76 Cal. App.2d 515, 525 [173 P.2d 392].)"
Relying upon People v. Santana, 206 Cal. App.2d 318 [23 Cal. Rptr. 602], appellant Jackson contends that the Youth Authority could not return him to the committing court without a showing that he was incorrigible or incapable of reformation. Appellant's reliance upon Santana is misplaced. In its factual and procedural aspects the cited case differs radically from the case at bench. The defendant Santana was charged with six counts of violating the narcotics laws. Upon arraignment defense counsel informed the court that the defendant was 19 years of age, that he had been addicted to narcotics and that the previously had been voluntarily committed to Camarillo State Hospital. Counsel also stated to the court that "anticipating that the defendant would be referred either to the Youth Authority or to the state hospital for treatment, he was willing to enter a plea of guilty at that time to count five  possession of heroin." The court stated that it would accept a plea of guilty to the one charge. Defendant accordingly entered his plea of guilty to the indicated count. The hearing on probation and sentence was set for a subsequent date and defendant was referred to the Youth Authority to ascertain whether or not the authority would accept him.
When the matter came on for hearing for probation and sentence, the trial judge advised counsel that the Youth Authority had informed him that defendant would be accepted. The court, however, further advised counsel that "I don't see how I can send this boy to the Youth Authority with the quantity of narcotics that are involved here." The court thereupon denied probation and sentenced defendant to state prison for the term prescribed by law. The defendant appealed contending that since he had been referred to the Youth Authority and since the authority had accepted him, the court was required under the law, and particularly under the provisions of the concluding paragraph of secton 1731.5 of the Welfare and Institutions Code, to commit him to the authority.
We sustained defendant's contention and reversed the judgment with *957 directions that the defendant be committed to the Youth Authority. Our decision was based primarily upon the mandatory language of the last sentence in the concluding paragraph of section 1731.5 above quoted.
In Santana the trial court erroneously sentenced the defendant to state prison after it had accepted his plea of guilty upon the indicated understanding that he would be referred to the Youth Authority, after the reference to the Youth Authority actually had been made, and after the Youth Authority had accepted him. In these circumstances the plain provisions of the statute as well as the obvious dictates of fairness required that the defendant be committed to the Youth Authority. (4b) In the case at bench, as we have seen, the trial court erroneously referred the ineligible appellants to the Youth Authority which, in the exercise of its statutory power under section 1737.1, rejected them as improper persons to be retained. They were accordingly returned to the trial court for sentencing in the manner prescribed by law.
It is settled law that (8) the authority is vested with broad discretionary powers in the acceptance or rejection of persons referred to it. "In selecting its cases the Authority is guided by appropriate legislative standards, namely, the adequacy of available facilities and the likelihood of benefit to the person accepted for treatment." (In re Herrera, 23 Cal.2d 206, 212 [143 P.2d 345].)
The basic argument of appellants that the authority exceeded its lawful powers in refusing to accept them is contradicted by the decision of the Supreme Court in In re Ralph, 27 Cal.2d 866, 870 [168 P.2d 1], wherein it was stated that "commitment to the Youth Authority can be only tentative, discretion to accept or reject a defendant being vested in the Authority.... The interpretation now suggested by petitioner would require the commitment to the Youth Authority of those obviously intended by the Legislature to be excepted; i.e., those who, following conviction, are subject to being `sentenced to death, imprisoned for life, imprisonment for not more than 90 days, or the payment of a fine'." Other arguments advanced by appellants are deemed not sufficiently substantial to require further discussion.
The judgments are, and each is, affirmed.
Roth, P.J., and Fleming, J., concurred.
