
884 So.2d 924 (2003)
Ex parte Charles PETERSON.
(In re State of Alabama
v.
Charles Peterson).
CR-02-0874.
Court of Criminal Appeals of Alabama.
August 1, 2003.
*925 Daniel Gary Hamm, Montgomery; and Richard K. Keith, Montgomery, for petitioner.
William H. Pryor, Jr., atty. gen., and Cecil G. Brendle, Jr., asst. atty. gen., for respondent.
PER CURIAM.
The petitioner, Charles Peterson, filed this petition for a writ of mandamus directing Judge Eugene Reese to grant his motion to dismiss the charges against him because of an alleged violation of the Double Jeopardy Clause. In December 1995, Peterson was indicted for capital murder for the intentional murder of Eddie Allen, the manager of a Burger King fast-food restaurant, during the course of a robbery. In 1997, pursuant to a plea agreement, Peterson's indictment was amended and he pleaded guilty to felony-murder and robbery in the first degree. Based on that guilty plea he was sentenced to 30 years in prison for the felony-murder conviction and 20 years in prison for the robbery conviction, the sentences to run consecutively.
In July 2000, Peterson filed a post-conviction petition attacking his convictions and sentences. The trial court denied the petition. Peterson appealed, and this Court remanded the case for the trial court to determine if the robbery conviction was based on the same set of facts as the felony-murder conviction. See Peterson v. State, 842 So.2d 734 (Ala.Crim.App.2001).[1] On remand, the trial court determined that the convictions were based on the same set of facts, and it vacated the robbery conviction, as this Court had directed it to do. The State then moved that Peterson's felony-murder conviction be set aside.[2] That motion was granted, and Peterson was indicted a second time in March 2002 for the capital offenses of murder during the course of a robbery and murder during the course of a burglary, and for conspiracy to commit robbery. The State filed a motion to nol-pros the first indictment charging capital murder, which had been amended when Peterson pleaded guilty to felony-murder and robbery. Peterson countered by filing a motion to dismiss the second indictment, arguing that jeopardy had attached when he pleaded guilty to felony-murder and robbery and that any further prosecutions for those offenses violated the Double Jeopardy Clause. The State argued that because the robbery conviction was included in the felony-murder conviction and the indictment charged only one count both convictions and sentences were due to be set aside. The trial court agreed and granted the State's motion to nol-pros the first indictment. The trial court denied Peterson's *926 motion to dismiss the second indictment; this petition followed.[3] The circuit court has stayed all proceedings in that court pending the outcome of this mandamus petition.
Apparently, Judge Reese did not make specific findings of fact for denying Peterson's motion to dismiss the second indictment; however, Judge Reese, when denying the motion to dismiss codefendant Karys Dontricia Murray's second indictment, made the following findings:
"This matter is before the court on the defendant's motion to dismiss the indictment based upon a claim of former jeopardy. Upon consideration of the pleadings and argument of counsel it is hereby ordered and decreed that the defendant's motion to dismiss the indictment based upon the ground of former jeopardy is due to be and is hereby denied.
"The defendant was first indicted by the Montgomery County Grand Jury on December 8, 1995, case no. CC-95-2373 for capital murder. Based on a plea agreement Mr. Murray pleaded guilty to felony murder and robbery I and was sentenced to two life sentences consecutive on June 16, 1997.
"One of the co-defendants, Charles Peterson, was originally indicted similarly in case no. CC-95-2408, and based upon a plea agreement pleaded guilty to felony murder and robbery I, but was sentenced to 30 years plus 20 years for a total of 50 years. However, co-defendant Peterson filed a Rule 32 petition challenging his convictions on double jeopardy grounds. The Alabama Court of Criminal Appeals stated in a November 30, 2001, opinion in Peterson's case (Criminal Appeals No. CR-00-2417) that if Peterson's convictions for both felony murder and robbery I were based on the same robbery, then his convictions violated double jeopardy principals.
"Based upon the Peterson case referred to above the district attorney re-presented the defendant and Peterson's cases to the grand jury. On or about March 8, 2002, the Montgomery County Grand Jury returned identical indictments against defendant and Mr. Peterson. In the new indictments [case no. CC-02-459 (Murray) and CC-02-248 (Peterson)] both defendants were charged with capital murder and conspiracy to commit robbery I.
"On May 14, 2002, this Court nolle prossed Mr. Murray's original indictment in case no. CC-95-2373.
"The State subsequently moved in case no. CC-95-2373 to vacate the original robbery I conviction and reinstate the original indictment. The state also moved to nolle pros the original indictment in case no. CC-95-2372 and represented that the state wished to prosecute the second indictment in case no. CC-02-459. The court subsequently granted those motions on September 16 and 18, 2002.
"The court finds based upon the case of Ex parte Cole, 842 So.2d 605 (Ala.2002), there is no double jeopardy in this case. (`A reindictment after a conviction that has been held to be void does not constitute double jeopardy.') Therefore, in order to clarify this Court's previous orders and to specifically allow the defendant to preserve this issue for review by appeal or mandamus the court denies the motion to dismiss based upon former jeopardy."
*927 Peterson cites Ex parte Cole, 842 So.2d 605 (Ala.2002), on remand, 842 So.2d 609 (Ala.Crim.App.2002), in support of his contention that his felony-murder conviction would stand even though his robbery conviction was set aside. Therefore, he argues that the trial court erred in setting aside the felony-murder conviction and that that error was compounded when he was indicted a second time for the same offense. The State argues that the entire plea is void because, it argues, the trial court had no jurisdiction to accept a guilty plea that was based on an illegal plea. It contends that the trial court cannot separate the convictions and uphold one portion of the charge.
The defendant in Cole was indicted in a two-count indictment for robbery in the first degree and assault in the first degree. Cole pleaded guilty to robbery in the second degree and assault in the second degree. The Court held that when Cole pleaded guilty to assault in the second degree, he pleaded guilty to a charge that was not included in the first-degree assault charge because the indictment failed to allege facts that fit within the definition of the offense of assault in the second degree. The Supreme Court upheld the robbery conviction but ordered that the assault conviction be vacated. The Court stated:
"Cole's conviction for first-degree assault, however, is unchallenged and therefore remains valid. Because the indictment charging him with first-degree robbery was improperly amended to charge second-degree robbery, Cole's original indictment charging first-degree robbery remains valid. The State may try Cole on this charge, or if the factual circumstances would support a conviction for another degree or robbery, the State may reindict Cole for the proper offense.... A reindictment after a conviction that has been held to be void does not constitute double jeopardy because, if a court is without jurisdiction, there can be no valid conviction; hence there is no jeopardy."
842 So.2d at 609. The Alabama Supreme Court in Cole did uphold one conviction and set aside the other conviction. However, Cole is distinguishable from this case. In Cole, the defendant pleaded guilty to two separate charges based on two separate counts in an indictment.
Here, Peterson pleaded guilty to two charges that arose out of a one-count indictment that was improperly amended when Peterson pleaded guilty. The indictment was amended to charge an offense that was not part of the original one-count capital murder indictment. The facts of this case are more akin to those presented to this Court in Hammond v. State, 665 So.2d 970 (Ala.Crim.App.1995). In Hammond, the defendant was indicted for the capital offense of robbery/murder and pleaded guilty to solicitation to commit unlawful distribution of a controlled substance. In upholding the court's setting aside of the guilty plea and Hammond's subsequent reindictment for the correct offense, this Court stated:
"The original capital murder-robbery indictment in this case was a valid indictment. In carrying out the plea agreement, the state attempted to amend the indictment by adding a separate count charging `solicitation to distribute a controlled substance,' Ala.Code 1975, § 13A-12-202. The amendment purporting to add this charge was void. An indictment may be amended by order of the court with the consent of the defendant in all cases, except to change the offense or to charge new offenses not contemplated by the original indictment. Ross v. State, 529 So.2d 1074 (Ala.Cr.App.1988); Ala.R.Cr.P. 13.5. In this case, the added charge is a substantial *928 change from the indictment returned by the grand jury and charges a new offense not included in the original charge. Thus, all proceedings stemming from the amendment of the indictment had no legal effect and were void.
"When the appellant challenged the proceedings in his post-conviction petitions, the trial court had no choice but to set aside this conviction and sentence. The appellant argues that once the proceedings stemming from the amendment were determined to be void, the original capital charge should not have been restored to the docket because, he argues, the indictment, as amended, was void and a re-indictment by the grand jury was necessary before the state could proceed under the capital charge. He relies on Ex parte Wesley, 481 So.2d 1162 (Ala.1985). However, we agree with the state that there was no amendment to the original indictment, only an unsuccessful attempt to amend the indictment by adding a count that was a nullity. Under these facts, when the guilty plea proceedings and the judgment based thereon were recognized as void and were set aside, it was proper for the trial court to order the original capital charge to be restored to the docket for trial. Williams v. State, 494 So.2d 819 (Ala.Cr.App.1986). Even if a charge has been nolle prossed, which is not the case here, further proceedings on that charge at a later time are not barred, and a person is not placed in double jeopardy when the state seeks to prosecute him on a previously dismissed charge, after his guilty plea to another charge has been vacated. Williams v. State, and cases cited therein. We think that Ex parte Wesley, upon which the appellant relies, is factually distinguishable from this case."
665 So.2d at 974 (footnote omitted; emphasis added). As we further stated in King v. State, 689 So.2d 931 (Ala.Crim.App.1997), "when the trial court accepts a defendant's guilty plea to an offense for which the defendant has not been indicted, the court's judgment is void because the court lacked jurisdiction." 689 So.2d at 932. "[T]he trial court cannot enforce such an agreement if it had no jurisdiction to accept the plea agreement and the pleas based on that agreement." 689 So.2d at 932 (footnote omitted). As we stated in Warren v. State, 706 So.2d 1316, 1318 (Ala.Crim.App.1997), quoting Brown v. State, 660 So.2d 235, 236 (Ala.Crim.App.1995), "`Any conviction entered by the court pursuant to the appellant's plea is set aside and the parties are returned to the status quo existing before the plea agreement.'"
For a writ of mandamus to issue the petitioner must show (1) a clear legal right in the petitioner to the relief sought; (2) an imperative duty upon the respondent to perform, accompanied by a refusal to do so; (3) the lack of another adequate remedy; and (4) properly invoked jurisdiction of the court. Ex parte Mardis, 628 So.2d 605, 606 (Ala.1993).
Because Peterson has failed to establish a clear legal right to the relief sought Peterson has failed to satisfy the prerequisites for the issuance of this writ. Here, the entire guilty plea was due to be set aside because it was based on an illegally amended indictment. Therefore, the parties were put in the posture of never having entered a plea to any charges in the indictment. The State could proceed on the original indictment or it could reindict Peterson  which it chose to do. See Cole, supra.
Peterson has failed to satisfy the prerequisites for the issuance of this writ of mandamus. This petition is due to be, and is hereby, denied.
PETITION DENIED.
*929 McMILLAN, P.J, and COBB, BASCHAB, and WISE, JJ., concur.
SHAW, J., not sitting.
NOTES
[1]  We did not address the validity of the entire plea agreement because the record in Peterson did not contain a copy of the indictment.
[2]  The State argued at the hearing on the motion to set aside the felony-murder conviction that because the robbery conviction was the basis of the charge that resulted in the felony-murder conviction, if the robbery conviction was set aside then both convictions were due to be set aside. A court can notice a jurisdictional defect at any time and has a duty to correct the defect. See Carpenter v. State, 782 So.2d 848 (Ala.Crim.App.2000).
[3]  Peterson's codefendant, Karys Dontricia Murray, filed a similar mandamus petition, CR-02-1149, with this Court. This Court denied that petition by order on August 1, 2003.
