
173 Cal.App.3d 766 (1985)
219 Cal. Rptr. 291
THE PEOPLE, Plaintiff and Respondent,
v.
DOUGLAS RAY MINK, Defendant and Appellant.
Docket No. E000336.
Court of Appeals of California, Fourth District, Division Two.
October 24, 1985.
*768 COUNSEL
Richard D. Rome, under appointment by the Court of Appeal, for Defendant and Appellant.
John K. Van de Kamp, Attorney General, Keith I. Motley and Tim J. Nader, Deputy Attorneys General, for Plaintiff and Respondent.
OPINION
KAUFMAN, J.
Defendant Douglas Ray Mink was accused of committing a number of robberies and other crimes within a relatively short period of time, including the robbery of Mr. and Mrs. Reed in their home. Originally, the Reed robberies, other robberies and other crimes were charged together in Riverside Superior Court case No. 21440. It was also alleged in that case that defendant had suffered a prior robbery conviction in Riverside County in April 1970.
Defendant filed a Penal Code section 995 motion in case No. 21440 which resulted in the dismissal of the Reed robberies because at the preliminary hearing the magistrate had not permitted defendant to present the testimony of Mrs. Reed. Case No. 21440 was then consolidated with another case, No. 21320, and the two consolidated cases proceeded to trial. Defendant was convicted of several offenses. However, in a separate trial to the court the prior robbery conviction allegation was found not true.
Meanwhile, prosecution of the robberies of Mr. and Mrs. Reed were reinstituted as case No. 21680, the instant case. Two counts of robbery (Pen. Code, § 211) were alleged together with firearm armed and use allegations (Pen. Code, §§ 12022, subd. (a), 12022.5) and it was further alleged that defendant had suffered a prior robbery conviction in Riverside County in April 1970, the same prior conviction alleged but found not true in case No. 21440.
Originally, defendant pleaded not guilty and denied the prior conviction allegation on the basis of subdivisions 4 and 5 of Penal Code section 1016  former judgment of acquittal and once in jeopardy. Defendant subsequently moved to strike the prior conviction allegation on the same grounds. His motion was denied.
Defendant thereafter presented a nonstatutory motion to dismiss on the ground that an impermissibly suggestive identification had taken place at *769 the preliminary hearing when the magistrate required defendant to identify himself in the presence of witnesses before they were called to testify and identify him. The motion to dismiss was also denied.
Thereafter defendant withdrew his plea of not guilty to the robberies and entered pleas of guilty to both counts. A court trial was had, however, on the prior conviction allegation, and the allegation was found true. Defendant was sentenced to the midterm of four years on each count of robbery, plus a two-year enhancement on each count for the firearm use and a one-year enhancement on each count for the armed finding, the latter being stayed. The sentences were, however, ordered to be served concurrently with each other and concurrently with the sentence imposed in consolidated cases 21440 and 21320. But a consecutive five-year enhancement was imposed on account of the prior conviction.
Defendant appeals, contending his motions to strike the prior conviction allegation and to dismiss should have been granted.

Facts
On July 9, 1983, Charles and Evelyn Reed were seated on the front porch of their home when defendant approached them, displayed a firearm, and robbed them.

Discussion

I
(1) In view of defendant's guilty plea, his contention the trial court erred in denying his motion to dismiss based on the assertedly unduly suggestive pretrial identification is not cognizable on appeal.
"Although [Penal Code] section 1237.5, subdivision (a) provides that the issues raised on an appeal after a guilty plea may be `constitutional, jurisdictional, or other grounds going to the legality of the proceedings,' the cases discussing this section make it clear that the constitutional issues raised must go to the legality of the proceedings. `Other than search and seizure issues which are specifically made reviewable by section 1538.5, subdivision (m), all errors arising prior to entry of a guilty plea are waived, except those which question the jurisdiction or legality of the proceedings.' (People v. Kaanehe [(1977) 19 Cal.3d 1, 9 (136 Cal. Rptr. 409, 559 P.2d 1028)].) `[I]t has been stated as a general principle that the "judgment entered on the plea of guilty is not appealable on the merits" and irregularities not going to the jurisdiction or legality of the proceedings will not be reviewed.' *770 (People v. Laudermilk (1967) 67 Cal.2d 272, 281-282 [61 Cal. Rptr. 644, 431 P.2d 228], cert. den. 393 U.S. 861 [21 L.Ed.2d 128, 89 S.Ct. 139]; People v. Warburton (1970) 7 Cal. App.3d 815, 821 [86 Cal. Rptr. 894], cert. den. 400 U.S. 1022 [27 L.Ed.2d 634, 91 S.Ct. 587].) ... [¶] ... The appellate courts have found themselves without jurisdiction, in cases involving appeals from judgments entered after guilty pleas, to consider issues such as the voluntariness of defendant's extrajudicial statement (when it is not the product of an allegedly unlawful search or seizure) (People v. DeVaughn [1977] 18 Cal.3d 889, 896 [135 Cal. Rptr. 786, 558 P.2d 872]), the trial court's refusal to postpone the trial (People v. Kaanehe, supra, 19 Cal.3d 1, 9), the trial court's denial of the motion to disclose the identity of the informant (People v. Barkins (1978) 81 Cal. App.3d 30, 33 [145 Cal. Rptr. 926]; People v. Castro (1974) 42 Cal. App.3d 960, 965 [117 Cal. Rptr. 295]), the sufficiency of evidence before the grand jury (People v. Meals (1975) 49 Cal. App.3d 702, 706-707 [122 Cal. Rptr. 585]), and the fairness of a pretrial lineup (People v. Stearns (1973) 35 Cal. App.3d 304, 306 [110 Cal. Rptr. 711])." (People v. Hayton (1979) 95 Cal. App.3d 413, 416-417, fn. omitted [156 Cal. Rptr. 426].)
Defendant's challenge on appeal to the trial court's denial of his motion to dismiss is, therefore, foreclosed by his guilty plea. (See People v. Shults (1984) 151 Cal. App.3d 714, 719-720 [199 Cal. Rptr. 33].)
The convictions therefore will be affirmed.

II
(2a) However, in the unique circumstances of this case we believe defendant's contention his motion to strike the alleged prior should have been granted is well taken.
Penal Code section 687 provides: "No person can be subjected to a second prosecution for a public offense for which he has once been prosecuted and convicted or acquitted." (3) Normally neither that statutory provision nor the constitutional guarantees against double jeopardy apply to successive trials of sentence enhancement allegations based on prior convictions because guilt or innocence is not the issue in a proceeding to determine whether a defendant has suffered a prior conviction. "The law is well established that ... the increased penalty for a prior is attributable solely to the new, rather than the former, crime and its purpose is to discourage recidivist criminal conduct (cf. In re Aaron N. (1977) 70 Cal. App.3d 931, 940 [139 Cal. Rptr. 258]; In re Propp (1967) 251 Cal. App.2d 896, 899 [60 Cal. Rptr. 23]; People v. Reed (1967) 249 Cal. App.2d 468, 472 [57 Cal. Rptr. 407]; People v. Stone (1945) 69 Cal. App.2d 533, 535 [159 P.2d *771 701]). As stated in People v. Biggs (1937) 9 Cal.2d 508, 512 [71 P.2d 214, 116 A.L.R. 205], `it is the second or subsequent offense which is punished, not the first'; and as amplified in People v. Dutton (1937) 9 Cal.2d 505, 507 [71 P.2d 218], `the increased punishment provided for subsequent offenders is not an additional disability attaching to the first offense, but an appropriate penalty for the person who, after conviction of one crime commits another.'" (People v. Johnson (1979) 95 Cal. App.3d 352, 357-358 [157 Cal. Rptr. 150], original italics.)
(2b) However, given the applicable statutory and decisional law that a sentence enhancement based on a prior conviction is to be appended not to the individual counts but to the aggregate sentence (Pen. Code, § 1170.1, subd. (a); People v. Tassell (1984) 36 Cal.3d 77, 90 [201 Cal. Rptr. 561, 679 P.2d 1]) and the somewhat unique procedural circumstances of this case, we believe defendant's plea of former acquittal to the prior conviction allegation was appropriate and dispositive.
The two counts of robbery of which defendant stands convicted in this case were originally pleaded as two counts in Riverside Superior Court case No. 21440. Had they remained a part of that case, no sentence enhancement on account of the alleged prior conviction could have been imposed as to those robberies because the court found the prior conviction allegation untrue. Thus, the sentence enhancement may arguably be attached to the Reed robberies only because they came to trial in a separate prosecution. However, the separate prosecution resulted only because defendant was denied a fundamental right at his preliminary hearing and the court was therefore required to grant defendant's Penal Code section 995 motion to dismiss the two counts charging the Reed robberies. Defendant's successful exercise of his statutory right to move for dismissal under Penal Code section 995 may not be penalized by affording the People two chances to prove the prior conviction rather than the one opportunity they would have had had defendant not successfully exercised his statutory right.
Having so concluded, it is unnecessary for us to attempt to resolve defendant's claim that collateral estoppel applies or the People's claim to the contrary, nor the People's further claim defendant waived the issue of collateral estoppel because he failed to raise it in the trial court.

III
(4) There remains the question of appropriate disposition. Defendant contends the appropriate disposition on appeal would be the striking of the five-year sentence enhancement. The People urge this court should more appropriately vacate the entire sentence and remand for sentencing, because *772 the consecutive five-year sentence enhancement was the primary if not the sole reason the trial court ordered the sentences on the robbery convictions to run concurrently with each other and the sentence in consolidated cases 21440 and 21320. Here, we agree with the People. In imposing the sentence it did, the court specifically stated: "There's no question the Court, were it of a mind to, could run everything here consecutively to the sentence in the other case and find more than sufficient reasons for doing so. But, again, I think, with the sentence in the other case, plus the five years, that that's the most I would have imposed under the circumstances, had all of the counts remained together." (Italics added.)
Accordingly, the convictions are affirmed, but the true finding on the prior conviction allegation is reversed with directions to the trial court to strike that allegation and thereafter to resentence defendant in accordance with law.
Morris, P.J., and McDaniel, J., concurred.
