
205 Cal.App.2d 53 (1962)
FRANK ADAMS, Petitioner,
v.
ROBERT A. HEINZE, as Warden of Folsom State Prison et al., Respondents.
Civ. No. 10518. 
California Court of Appeals. Third Dist.  
June 25, 1962.
 Frank Adams, in pro. per., for Petitioner.
 Stanley Mosk, Attorney General, and Nat Agliano, Deputy Attorney General, for Respondents.
 SCHOTTKY, J.
 Frank Adams, an inmate of Folsom Prison, seeks a writ for the purpose of vacating one of two sentences he is now serving. [1] The petition, though labeled mandate, will be treated as one for habeas corpus which is the proper remedy to review the question whether the court exceeded its jurisdiction in imposing sentence on both counts. (Neal v. State of California, 55 Cal.2d 11 [9 Cal.Rptr. 607, 357 P.2d 839].)
 The facts as conceded by the Attorney General disclose: Woodrow Fleming was employed as a janitor at the Mayfair Market. On August 22, 1958, he went to work as usual. At approximately 2:45 a. m., as he was cleaning the store, he heard a voice say, "Come to me, pal." Looking up, Fleming saw petitioner a short distance away holding a gun in his hand. After a brief hesitation, Fleming approached petitioner as ordered. Petitioner said, "Let's go upstairs," and he marched Fleming up the stairs. Arriving at the second- floor landing, petitioner said, "Turn left; go to the office." At the office door he told Fleming to lie down. Petitioner then unlocked the office door and told Fleming to get up and enter the office. When Fleming entered he was again ordered to lie on the floor.
 The office door had automatically closed after they entered. Petitioner went over to Fleming and asked him how to open the door from the inside, and particularly so the alarm would not go off. Fleming told him that he had to press a button. Petitioner then ordered Fleming to go to the door with him so they could try it. Fleming obeyed, and when the door was opened petitioner ordered Fleming back to where he had been lying on the floor. Fleming obeyed this order also.
 Petitioner then took a handkerchief out of Fleming's right back pocket and went toward the office safe. In a few minutes Fleming heard the buzzer go off and petitioner running down the stairs and presumably out of the building. The safe was now open and the money which it had contained was missing.
 Petitioner contends that his conviction and sentence for the crime of kidnaping for the purpose of robbery and for robbery constitute double punishment in violation of section 654 of *55 the Penal Code. We have concluded that this contention must be sustained.
 [2] As stated in Neal v. State of California, 55 Cal.2d 11 [9 Cal.Rptr. 607, 357 P.2d 839], at page 19: "Whether a course of criminal conduct is divisible and therefore gives rise to more than one act within the meaning of section 654 depends on the intent and objective of the actor. If all of the offenses were incident to one objective, the defendant may be punished for any one of such offenses but not for more than one."
 [3] A study of the record convinces us that the kidnaping was a mere incident of the robbery and not separate therefrom. The kidnaping for the purpose of robbery sentence, the more serious of the two offenses for which Adams was sentenced, is the only one for which Adams may be punished. The robbery conviction must be set aside. (People v. Velarde, 201 Cal.App.2d 231 [19 Cal.Rptr. 832].)
 And paraphrasing the statement of Mr. Justice Pierce of this court in Downs v. State of California, 202 Cal.App.2d 609 [20 Cal.Rptr. 922], the record here compels a conclusion that the plan was preconceived as to the robbery. Petitioner entered the market with the single intent to rifle its safe, hoping no doubt that this could be accomplished without interference, but prepared for that event by carrying a gun which he intended to use, and did threaten to use, to consummate the crime. While in Downs the crimes were burglary and robbery and here kidnaping for the purpose of robbery and robbery, in both cases the commission of two crimes was a mere incident to the completion of the basic purpose--to obtain money from a safe.
 As was said in People v. Kehoe, 33 Cal.2d 711 [204 P.2d 321], at page 715: "Accordingly, although it was proper to charge Kehoe with both crimes in the information and the record would support his conviction of either of them, it was error for the court to enter a judgment finding him guilty of both offenses. Since he was found guilty of grand theft, the lesser crime of violation of section 503 may be said to have merged into that conviction. Although the sentences were ordered to run concurrently, to 'preclude the dual judgments of the trial court from hereafter working any possible disadvantage or detriment to the defendant in the later fixing of his definite term of the [Adult Authority]' (People v. Craig, 17 Cal.2d 453, 458 [110 P.2d 403]), the judgment, insofar as it finds Kehoe guilty of a violation of section 503 *56 of the Vehicle Code, is reversed with directions to the trial court to dismiss count two of the information. ..."
 [4] Petitioner also contends that it was improper for him to be charged with these two crimes when he could only be sentenced for one. There is no merit to this contention. Section 954 of the Penal Code reads in part: "An accusatory pleading may charge two or more different offenses connected together in their commission. ..."
 In view of the foregoing, we conclude petitioner's conviction of robbery should be set aside and the Adult Authority is directed to exclude from its consideration the purported sentence for robbery. The petitioner, however, is not entitled to his release so long as he is held under a valid judgment of conviction of the crime of kidnaping for the purpose of robbery.
 The order to show cause heretofore issued is discharged and the petition for habeas corpus is denied.
 Peek, P. J., and Pierce, J., concurred.
