Opinion by Judge REINHARDT; Partial Concurrence and Partial Dissent by Judge RYMER.
REINHARDT, Circuit Judge:Most readers of this opinion will be well acquainted with the activities of Charles Keating, whose corporations, American Continental Corporation and Lincoln Savings & Loan, bilked elderly individuals out of millions of dollars of savings by selling them worthless savings bonds. Keating was prosecuted in both federal and state court, and sentenced to substantial terms of imprisonment, to be served concurrently. He ultimately spent five years in prison. His federal and state trials were both marred, however, by errors which led our court to reverse his federal conviction1 and a federal district court to grant his state habeas petition. Following these actions, Keating was released from prison prior to the completion of his prison sentences. At the time, only six months remained before he would have become eligible for parole on his state sentence. Keating subsequently pleaded guilty to the federal charges and, pursuant to a plea agreement, was sentenced to time served.
We now consider whether the district court’s decision granting Keating habeas relief from his state conviction was legally correct. The decision was based on the ground that the jury instruction defining the offense of securities fraud erroneously omitted the mens rea element. We affirm the district court’s holding that the omission of this essential element of the offense violated due process and requires the reversal of Keating’s conviction.
I.
BACKGROUND
In 1990, Keating was indicted in California state court for violating sections 25401 and 25540 of the California Corporations Code, which make it a criminal offense to offer or sell a security “by means of any written or oral communication which includes an untrue statement of material fact necessary in order to make the statements made, in light of the circumstances under which they were made, not misleading.” The state contended, in essence, that the bond sellers were misled by Keating’s failure to inform them of American Continental’s poor financial condition and the riskiness of the bonds, and that they, in turn, *1056unwittingly misled the bond purchasers. It is undisputed that in 1989, when American Continental’s financial circumstances had deteriorated to the point where the company was no longer able to make payments on the bonds, it filed for bankruptcy and most of the bond purchasers lost the money they had invested.2
Prior to trial, the judge informed the jury that Keating could be held criminally responsible either as a direct perpetrator or for aiding and abetting the offense. Before the parties’ closing arguments, however, a dispute erupted over whether a direct perpetrator theory of liability would be presented to the jury. The defense requested a jury instruction that, because Keating had not personally sold or offered the securities to the purchasers, he could only be convicted as an aider and abettor. The prosecution objected, informing the court that it planned to argue both theories to the jury. Keating renewed his protest, pointing out that he had had no face-to-face contact or direct communication with the individuals named in the indictment, and the trial judge concurred with his skepticism about the direct perpetrator theory. The prosecutor countered that a direct perpetrator instruction was “supported in an evidentiary sense” if Keating was viewed as the original source of the offer and of the misleading omission of information. The prosecution characterized Keating “as the alter ego for the corporation” and stated that in its view “the gravamen of the offense ... is not so much an actual sale as it is the omission or misrepresentation aspect of it.” This theory identified Keating as the source of the failure to notify anyone of the financial risks of the bonds, a material omission that was ultimately transmitted to the bond purchasers, and that was “violative of the statute just as much as an actual sale.” As the judge’s discomfort with the prosecution’s theory of liability became increasingly clear, the prosecution urged one last possible way to view Keating as a direct perpetrator:
[O]ne thing the evidence does demonstrate is that it was the defendant who singly was setting the terms of the offer, interest rates in the offer, maturity dates in the offer and that [American Continental] was promulgating various material in the form of track records, annual reports and the like that were utilized as part of an offer as well for these individuals. And I would state in that regard, the bond seller becomes a communicator of that; but it is the defendant again who is the source of the bond.
The judge was not convinced. While acknowledging that “both theories are in a technical sense before the jury,” he concluded that the direct perpetrator theory was inconsistent with both the wording of the indictment, which charged “a completed sale” rather than an offer, and the statute under which the prosecution had charged Keating. The defendant continued to urge the judge to offer the instruction that Keating could only be convicted as an aider and abettor, arguing that the need for such an instruction was clearly demonstrated by the prosecution’s insistence that a direct perpetrator theory was supported by the evidence. Realizing that if it did not back off of its insistence that a direct perpetrator theory was viable, the judge would give the instruction proposed by the defense, the prosecution promised to argue the case only under an aiding and abetting theory.
When the defense attorney later renewed his request for an instruction limiting the basis on which Keating could be convicted, the judge announced, “I had previously declined to so instruct because I think the evidence is clear that Mr. Keat-ing never actually had any face-to-face contact with any of the bond purchasers. *1057So clearly his only liability can be as an aider and abettor. I think that’s already abundantly clear.”
After closing arguments, which are discussed in greater detail later in .this opinion, the judge instructed the jury.3 Because the content of the jury instructions is of paramount importance in this case, they are excerpted here:
Every person who willfully sells or offers to sell a security in this state by means of any written or oral communication which includes an untrue statement of a material fact or omits to state a material fact necessary in order to make the statements made, in light of the circumstances under which they were made, not misleading, is guilty of a violation of sections 25401/25540 of the California Corporations Code.
In order to prove such crime, each of the following elements must be proved:
1. The defendant willfully sold or offered to sell a security in the state of California;
2. By means of any written or oral communication which includes an untrue statement of material fact or omits to state a material fact necessary in order to make the statements made, in light of the circumstances under which they were made, not misleading.
The term “offer” or “offer to sell” includes every attempt or offer to dispose of, or solicitation of an offer to buy, a security or an interest in a security for value.
The term “sale” or “sell” includes every contract of sale of, contract to sell, or disposition of, a security or interest in a security for value.
The persons concerned in the commission of a crime who are regarded by laws as principals in the crime thus committed and equally guilty thereof include:
1. Those who directly and actively commit the act constituting the crime, or;
2. Those who aid and abet the commission of the crime.
Trial Transcript at 7468-70.
The jury was then instructed that, in order to convict Keating under the aiding and abetting theory, it would have to find that he knew that the bond sellers were making untrue statements or omitting material facts and that he intended, to facilitate, encourage or promote these untrue statements or omissions.4
Two key facts are apparent from a reading of the instructions. First, the instructions did not limit the jury to an aiding and abetting theory, but outlined' two possible bases for Keating’s. criminal liability and allowed the jury to convict him on either theory it deemed proven. Second, the instructions allowed the jury to convict Keat-ing as a direct perpetrator without finding that he had any knowledge of the falsity of the information that he conveyed or that he was negligent or reckless for failing to know; in other words, with respect to the direct perpetrator theory, the instructions contained no mens rea requirement. This *1058was consistent with the interpretation that the California Court of Appeals had given the law at the time. See People v. Baumgart, 267 Cal.Rptr. 534, 540-41, 218 Cal. App.3d 1207, 1219-20 (Cal.Ct.App.1990) (concluding that §§ 25401 and 25540 required no criminal intent); People v. Johnson, 262 Cal.Rptr. 366, 369, 213 Cal.App.3d 1369, 1375 (Cal.Ct.App.1989) (same).
The jury returned a verdict convicting Keating of seventeen of the eighteen charged counts of sales of securities by means of false statements or omissions. This general verdict did not specify whether the jury convicted Keating as a direct perpetrator or as an aider and abettor.
Keating appealed, and his conviction was affirmed by the California Court of Appeals. The court rejected Keating’s argument that the trial judge had erred by instructing the jury on a direct perpetrator theory for which there was insufficient evidence. It acknowledged that the “[t]he trial court presented the case to the jury with instructions that conviction was possible under theories that Keating was either the direct seller or a principal who was aiding and abetting the violation,” but reasoned that “[a] reading of these instructions indicates to this court, as it must have to the jurors, that Keating was being tried on the theory that he aided and abetted in the sales of the ‘junk bonds.’ ” People v. Keating, 19 Cal.Rptr.2d at 916, 920. The court also denied Keating’s claim regarding the failure to give the instruction limiting the jury’s considerations to the aider and abettor theory, reasoning, “[cjlearly, Keating never personally sold any security to any of the individual investors.... It is inconceivable that there was any need to give this instruction. To have given this instruction would be stating the obvious.” Id. at 920. Finally, the court rejected Keating’s argument that the omission of the mens rea element was an error, relying on previous decisions by the California Court of Appeals defining §§ 25401 and 25540 as establishing a strict liability offense. See Keating, 19 Cal.Rptr.2d at 917-18.
The California Supreme Court initially granted Keating’s petition for review. See People v. Keating, 23 Cal.Rptr .2d 593, 859 P.2d 673 (Cal.1993). Before it decided his case, however, it decided People v. Simon, 9 Cal.4th 493, 37 Cal.Rptr.2d 278, 886 P.2d 1271 (1995), in which it held that “knowledge of the falsity or misleading nature of a statement or of the materiality of an omission, or criminal negligence in failing to investigate and discover them” is required to convict a defendant of violating §§ 25401 and 25540, overruling the Court of Appeals decisions that held otherwise. Simon, 37 Cal.Rptr.2d 278, 886 P.2d at 1281, 1290. Then, rather than proceeding with its review of the Court of Appeals’ rejection of Keating’s appeal (a decision based on two cases that the, Supreme Court had now disavowed), the Supreme Court dismissed Keating’s petition without review as improvidently granted. See People v. Keating, 39 Cal.Rptr.2d 410, 890 P.2d 1119 (Cal.1995).
A few months after the California Supreme Court dismissed his petition, Keat-ing filed a petition for habeas relief in federal district court. The court granted Ms petition based on two grounds: that the failure to include a mens rea requirement in the direct perpetrator instruction eliminated an essential element of the offense from the jury’s consideration and therefore violated due process, and that the omission of this element also infected Keating’s conviction by allowing the jury to convict Mm as an aider and abettor without finding that the direct perpetrator had the requisite criminal intent. Keating v. Hood, 922 F.Supp. 1482, 1486-88, 1492-94 (C.D.Cal.1996).5 The state appealed this decision, and on January 15, 1998 this Court dismissed Keating’s petition without prejudice because of his failure to exhaust *1059his secondary claim, that the absence of a mens rea element in the direct perpetrator instruction had also infected any conviction on the aiding and abetting theory. Keating v. Hood, 133 F.3d 1240, 1241-42 (9th Cir.1998).
Rather than filing a petition for rehearing in this court or pursuing the secondary claim in state court, Keating decided to waive that claim. Accordingly, on January 22, 1998, he again filed the same habeas petition in the district court, this time omitting the secondary claim. On February 3,1998, shortly before the hearing that the district court had scheduled to discuss the new petition, the State Department of Corrections sent Keating a letter informing him that it expected the mandate of this Court to issue on February 5 and ordering him to surrender to state prison authorities at 3:00 p.m. on February 6 in order to finish serving his sentence.
The district court held an expedited hearing on February 5, at which time it verbally granted Keating’s habeas petition on the ground that the omission of the mens rea element from the direct perpetrator instruction violated due process. In doing so, the court first rejected the state’s challenge to its jurisdiction over the petition. At the time he filed the new petition, Keating was no longer in prison, and our mandate had not yet issued on the decision which dismissed his appeal and reinstated his conviction; thus, the state argued, the district court’s decision granting his habe-as petition remained in effect, and he could not be considered “in custody” for jurisdictional purposes. To address the state’s concerns, the court offered to delay the habeas proceeding as long as the state would promise that Keating would remain free from state custody until the district court could rule on his petition. However, the state was unwilling to make such a commitment. The court then decided that it had jurisdiction to consider Keating’s petition, analogizing his position to that of a defendant who is released on his own recognizance pending appeal, and holding that the state’s announcement of its plans to reincarcerate him subjected him to “a significant restraint upon his liberty.”
In reaching its decision on the merits of the petition, the court rejected the state’s argument that the absence of any evidence to support the direct perpetrator theory made it clear that the jury had convicted Keating as an aider and abettor and thus rendered the instructional error harmless. The court relied on the facts that the prosecutor had argued to the trial judge that there was sufficient evidence to justify a direct perpetrator instruction, and that in his closing argument to the jury the prosecutor had employed language, analogies and reasoning that suggested direct perpetrator liability.
Our mandate issued on February 5, 1998, and the next day the district court filed its written order granting Keating’s habeas petition.6 The state has appealed the district court’s ruling, objecting both on jurisdictional grounds and on the merits.
II.
JURISDICTION
The state raises a jurisdictional challenge, arguing that Keating was not “in custody” at the time that he filed his new habeas petition because he had been freed on the first petition and the mandate had not yet issued on this Court’s decision dismissing that petition for failure to exhaust state remedies. Thus, the state reasons, we do not have jurisdiction over the *1060new petition. The sequence of events causes us to reach a different conclusion. Keating’s first petition was not actually dismissed until February 11, after our mandate had issued. Well before February 11, Keating had filed a new petition omitting the unexhausted claim. The new petition simply restated Keating’s primary claim and dropped the secondary one. The district court treated his filing as a second petition; however, because the first petition had not yet been dismissed, and because, as the district court stated, “[t]he grounds [in the instant petition] are identical to those stated in the 1995 petition,” the new petition would more properly be regarded as an amended petition deleting the unexhausted claim. See Rose v. Lundy, 455 U.S. 509, 510, 102 S.Ct. 1198, 71 L.Ed.2d 379 (1982) (when habeas petition has been dismissed for failure to exhaust, petitioner has “the choice of returning to state court to exhaust his claims or of amending or resubmitting the habeas petition to present only exhausted claims to the district court.”); Calderon v. U.S.D.C. (“Thomas”), 144 F.3d 618, 620 (9th Cir.1998) (discussing district court’s power to allow amendment of habeas petition to strike unexhausted claims); Calderon v. U.S.D.C. (“Taylor”), 134 F.3d 981 (9th Cir.1998) (“The Supreme Court in Rose specifically provided habeas petitioners with the option of amending their applications to delete unexhausted claims rather than suffering a dismissal”); Guizar v. Estelle, 843 F.2d 371, 372 (9th Cir.1988) (under Rose v. Lundy, petitioners “should have the option of either resubmitting their petitions with only exhausted claims, or exhausting the remainder of their claims in state court and then filing new petitions.... [If petitioner] resubmit[s] his petition with only the exhausted claims, ... the district court may accept it nunc pro tunc and reinstate its opinion.”).7 We now hold that the instant petition may be treated as an amendment or resubmittal of Keating’s first ha-beas petition, and instruct the district court to deem it as having been so filed, nunc pro tunc, under case number CV 95-5151 JGD.8 See Calderon v. U.S.D.C. (“Kelly”), 163 F.3d 530, 540 (9th Cir.1998) (en banc), cert. denied, — U.S. -, 119 S.Ct. 1377, 143 L.Ed.2d 535 (1999) (noting that district court could exercise nunc pro tunc power to deem recently filed habeas petitions to have been filed as of the filing date of two earlier petitions that were erroneously dismissed); Miller v. Laird, 464 F.2d 533, 534-35 (9th Cir.1972) (filing of amended petition relates back to date of original petition for purposes of in custody requirement).9 Because Keating’s first pe*1061tition was filed before the effective date of the Antiterrorism and Effective Death Penalty Act, the provisions of the AEDPA do not govern resolution of this case. See Lindh v. Murphy, 521 U.S. 320, 327, 117 S.Ct. 2059, 138 L.Ed.2d 481 (1997) (AED-PA does not apply to petitions pending on date of enactment).10
III.
DUE PROCESS
It is not disputed that the omission of the mens rea element from the direct perpetrator Instruction was erroneous under People v. Simon, 9 Cal.4th 493, 37 Cal.Rptr.2d 278, 886 P.2d 1271 (1995). At issue is whether this error in instructing the jury constituted a violation of federal due process compelling the grant of habeas relief.
Instructions that allow a jury to convict without finding every element of the offense violate In re Winship’s requirement that “every fact necessary to constitute the crime” must be proven beyond a reasonable doubt. In re Winship, 397 U.S. 358, 364, 90 S.Ct. 1068, 25 L.Ed.2d 368 (1970). Due process “require[s] criminal convictions to rest upon a jury determination that the defendant is guilty of every element of the crime with which he is charged, beyond a reasonable doubt.” United States v. Gaudin, 515 U.S. 506, 510, 115 S.Ct. 2310, 132 L.Ed.2d 444 (1995). Therefore, an instruction that relieves the state of the burden of proving mens rea beyond a reasonable doubt contradicts the presumption of innocence and invades the function of the jury, thereby violating due process. See Sandstrom v. Montana, 442 U.S. 510, 521-24, 99 S.Ct. 2450, 61 L.Ed.2d 39 (1979). As the Seventh Circuit noted, “every federal court to consider the question since the Court decided In re Winship ... has agreed that a conviction procured without any jury instruction on an essential element of the offense is constitutionally invalid.” Cole v. Young, 817 F.2d 412, 424 (7th Cir.1987). See also Osborne v. Ohio, 495 U.S. 103, 122-24 & n. 17, 110 S.Ct. 1691, 109 L.Ed.2d 98 (1990) (omission of element from jury instructions violates due process); United States v. Mendoza, 11 F.3d 126, 128 (9th Cir.1993) (“[W]hen a trial judge omits an element of the offense charged from jury instructions, it deprives the jury of its fact-finding duty and violates the defendant’s due process rights”). It is .therefore clear that the omission of the mens rea element from the instructions to the jury violated Keating’s right to due process .by allowing the jury to convict him without finding a requisite element of the offense.11
*1062IV.
HARMLESS ERROR ANALYSIS
The Supreme Court has recently made it clear that harmless error analysis is required even when an element of an offense has been entirely removed from the jury’s consideration. See Neder v. United States, — U.S. -, 119 S.Ct. 1827, 144 L.Ed.2d 35 (1999). The burden of demonstrating that the error was harmless belongs to the government. See O’Neal v. McAninch, 513 U.S. 432, 444-45, 115 S.Ct. 992, 130 L.Ed.2d 947 (1995).
The state argues that the omission of the mens rea element from the jury instruction was harmless, but only on a very specific ground. The state does not argue that even if the jury convicted Keating :as a direct perpetrator the instructional error was harmless because “the omitted element was uncontested and supported by overwhelming evidence, such that the jury-verdict would have been the same absent the error.” Neder, supra. Nor does it contend that a review of the record would establish, under the applicable harmless error standard, that the jury would have found that Keating had the mens rea required under the statute, rendering any due process violation harmless. Instead, the state contends that the error was harmless because the jury convicted Keat-ing as an aider and abettor rather than as a direct perpetrator, and thus did not rely on the legally erroneous theory. At oral argument, counsel for Keating stated on several occasions that the state had conceded that the error was not harmless if Keating was convicted as a direct perpetrator, and the state did not contest this statement. Thus, there can be no question that the state’s decision not to assert that the error was harmless if the conviction was based on the direct perpetrator theory was knowing and deliberate.
The fundamental rule that applies when a jury delivers a general verdict that may rest either on a legally valid or legally invalid ground is clear: the verdict may not stand when there is no way to determine its basis. “It has long been settled that when a case is submitted to the jury on alternative theories the unconstitutionality of any of the theories requires that the conviction be set aside.” Sandstrom, 442 U.S. at 526, 99 S.Ct. 2450. See also Yates v. United States, 354 U.S. 298, 312, 77 S.Ct. 1064, 1 L.Ed.2d 1356 (1957), overruled on other grounds, Burks v. United States, 437 U.S. 1, 98 S.Ct. 2141, 57 L.Ed.2d 1 (1978) (“[T]he proper rule to be applied is that which requires a verdict to be set aside in cases where the verdict is supportable on one ground, but not on another, and it is impossible to tell which ground the jury selected”); Stromberg v. California, 283 U.S. 359, 368, 51 S.Ct. 532, 75 L.Ed. 1117 (1931) (“[I]f any of the clauses in question is invalid under the Federal Constitution, the conviction cannot be upheld”). When two theories are presented to a jury and one is factually insufficient, a conviction may be upheld, because a jury is “equipped to analyze the evidence” and so a court may assume that it rested its verdict on the ground that the facts supported. Griffin v. United States, 502 U.S. 46, 59, 112 S.Ct. 466, 116 L.Ed.2d 371 (1991). However, since “[j]urors are not generally equipped to determine whether a particular theory of conviction submitted to them is contrary to law,” a conviction must be overturned if one of the theories that was submitted to the jury was legally erroneous. Id.
We have consistently interpreted Supreme Court precedent to require reversal in any case in which a verdict may have rested on a legally invalid ground. See United States v. Qualls, 140 F.3d 824, 829 (9th Cir.), vacated on other grounds, — U.S. -, 119 S.Ct. 398, 142 L.Ed.2d 323 (1998) (“[T]he Supreme Court has determined that a verdict must be set aside in cases such as this where the verdict is legally insupportable on one ground, yet supportable on another, and it is impossible to tell on which ground the jury relied.”); United States v. Fulbright, 105 F.3d 443, 451 (9th Cir.), cert. denied, 520 U.S. 1236, 117 S.Ct. 1836, 137 L.Ed.2d 1041 (1997) (“[T]he jury instructions per*1063mitted the jury to choose a basis for conviction that was legally impermissible.... Because we have no way to ascertain the factual basis on which the jury convicted Fullbright, his conviction under Count II cannot stand.”); United States v. Barona, 56 F.3d 1087, 1098 (9th Cir.1995) (“Where the jury is presented with a legally inadequate theory, as opposed to a factually inadequate theory, Yates requires that the conviction be vacated”). We have applied the same reasoning in habeas cases, hold: ing that, even when the evidence supporting the legally correct theory was “very strong” and the state did not argue the legally erroneous theory to the jury, the conviction must be reversed when it is not possible to determine whether the jury relied upon the erroneous theory to convict the defendant. See Suniga v. Bunnell, 998 F.2d 664, 667, 669-70 (9th Cir.1993). We have noted that instructing the jury on a legally erroneous theory in a case in which it is also instructed on a legally correct theory is particularly damaging when the jurors are not required to agree unanimously on the theory of conviction; in such cases, the possibility that even one juror might have relied upon the legally erroneous theory requires invalidation of the conviction. See id. at 669.
There is a limited exception to the principle: reversal may not be required if “it is absolutely certain” that the jury relied upon the legally correct theory to convict the defendant. Ficklin v. Hatcher, 177 F.3d 1147, 1151 (9th Cir.1999) (emphasis in original). In Ficklin, the jury had been erroneously instructed that it could convict a defendant of murder under an implied malice theory if it found that the murder was committed as part of a robbery attempt.12 However, the jury had also been correctly instructed that it could convict the defendant of first degree murder only if it found that the defendant had committed a “wilful, deliberate and premeditated killing.” Id. at 1151. The defendant was convicted of first degree murder. Ficklin held that the jury’s guilty verdict on the first degree murder charge demonstrated that the implied malice theory “could not have played a part in the jury’s determination.” Id. at 1151. However, the court explained that affirmance of a conviction when the jury was instructed on a legally erroneous theory was permissible only in “situations in which this Court determines that it was impossible for the jury to have relied on the infirm instruction,” and that its decision did “not suggest that a general verdict can be sustained if there is ‘ample’ evidence presented on a constitutional theory or if the prosecution ‘relied primarily’ on a constitutional theory.” Id. at 1152 (emphasis in original).
We cannot say that it is “absolutely certain” that the jury did not rely on the legally erroneous direct perpetrator theory to convict Keating. Unlike in Ficklin, Keating’s jury did not make any finding that renders it “impossible” that it convicted him as a direct perpetrator. Because of the absence of any such finding, and because the jury was not instructed that it could convict Keating only as an aider and abettor, we cannot determine with certainty that the jury rested its verdict on that theory.13
We reject the state’s argument that the conviction of Keating as a direct perpetrator was rendered impossible by the absence of any argument or evidence presented in support of such a theory.14 *1064This argument is contradicted by the prosecutor’s own statements at trial. After the close of the evidence, the prosecutor vigorously argued to the judge that Keating could be held criminally liable as a direct perpetrator.15 Moreover, although the prosecutor did not expressly ask the jury to convict Keating as a direct perpetrator, the language, analogies, and reasoning employed in his closing argument can readily be interpreted as conveying a theory of direct perpetrator liability to the jurors: that Keating was the source of the offers to the bond sellers and was directly responsible for the omission of material information from these offers.16
For the reasons set forth above, we cannot conclude that the instructional error was harmless.17
*1065IV.
CONCLUSION
Because the jury may have convicted Keating as a direct perpetrator, the omission of an essential element of the offense from the jury instructions violated due process and requires a grant of habeas relief. Accordingly, we AFFIRM the district court’s grant of such relief. The mandate will be held pending a limited remand to permit the district court to enter the nunc pro tunc order described in this opinion.
AFFIRMED.
. See United States v. Keating, 147 F.3d 895 (9th Cir.1998) (holding that jurors’ knowledge that Keating had been convicted in state court of offense arising out of same factual circumstances required reversal of federal conviction).
. We discuss the facts of his alleged state crimes only insofar as they are relevant to the errors in jury instructions that infected Keat-ing’s state trial. For a more detailed discussion of the conduct underlying the state charges, see People v. Keating, 16 Cal.App.4th 280, 19 Cal.Rptr.2d 899 (Cal.Ct.App.1993).
. After closing arguments, defense counsel renewed his objection to the trial judge’s refusal to give the requested instruction.
. The instruction on aiding and abetting required that the jury find the following:
1. An untrue statement of material fact or omission of a material fact was made by bond sellers in connection with the sale of bonds to the bond buyers identified in counts II through XVIII and XX, inclusive, of the indictment, and;
2. The defendant had knowledge that the bond sellers were making an untrue statement of material fact or omitting a material fact in the sales involved in each count, and;
3. The defendant intended to aid, encourage or facilitate the bond sellers in making an untrue statement of material fact or omitting a material fact in the sales involved in each count, and;
4. The defendant, by act or advice, intentionally aided, promoted, encouraged or instigated the making of the untrue statements of material facts or the omission of material facts.
Trial Transcript at 7470-71.
. Keating was not immediately released because he was still serving time for his federal conviction. Based on the progress of his direel appeal of that conviction, he was released on federal bond six months later, on October 3, 1996.
. The Decision to Grant the habeas petition actually became effective on February 11, the date that the written order granting Keating’s petition was entered on the docket. See Fed. R. Civ. Pr. 79(A) ("A judgment is effective only when so set forth and when entered as provided in Rule 79(a).”); 46 AM. JUR. 2D JUDGMENTS § 135 (1994) ("Entry of judgment occurs only when (1) the essentials of the judgment or order are set forth in a written document separate from the court's opinion or memorandum and (2) when the substance of the separate document is reflected in an appropriate notation on the docket sheet.”).
. The fact that Keating labelled the petition a second petition rather than an amended petition is not dispositive. It is often necessary to look beyond the labels that a party selects. See Thompson v. Calderon, 151 F.3d 918, 920 (9th Cir.1998) (en banc) (petitioner's motion for relief from judgment under Federal Rule of Civil Procedure 60(b) must be construed as successive habeas petition); National Org. for Reform of Marijuana Laws v. Mullen, 828 F.2d 536, 541 (9th Cir.1987) (court has discretion to treat appeal as petition for writ of mandamus).
. Because of the manner in which we resolve the jurisdictional issue, we need not determine whether the district court was correct in concluding that Keating was in custody when the January 22nd petition was filed. We simply note that he makes a strong argument that he was. Only the slim possibility of a sua sponte request for en banc rehearing stood between Keating and reimprisonment. See Hensley v. Municipal Court, 411 U.S. 345, 351-52, 93 S.Ct. 1571, 36 L.Ed.2d 294 (1973) (petitioner released on recognizance pending execution of sentence is in custody because "subject to restraints not shared by the public generally” and faces imminent threat of incarceration) (internal quotation marks and citation omitted); Vargas v. Swan, 854 F.2d 1028, 1030-31 (7th Cir.1988) (unlikely possibility that INS would decline to take custody of petitioner under detainer warrant does not deprive court of jurisdiction). Moreover, Keating was unquestionably in custody with respect to his federal conviction, under a federal bond and subject to restraints on his freedom of movement. A habeas petitioner who is in custody under one conviction may use the writ to challenge a future sentence. See Estelle v. Dorrough, 420 U.S. 534, 95 S.Ct. 1173, 43 L.Ed.2d 377 (1975).
. Henry v. Lungren, 164 F.3d 1240, 1241 (9th Cir.1999), is not to the contrary. In that case, after the district court dismissed his first ha-beas petition and failed to retain jurisdiction *1061over it, the petitioner refiled in state court in order to exhaust his claims. Accordingly, unlike in this case, the dismissal took effect and, following termination of the state court proceeding, the petitioner was required to file a second petition.
. We find Judge Rymer's disapproval of our holding on the jurisdictional question odd in view of her "pragmatic” attitude toward the filing of premature habeas petitions and appeals. With regard to the "flip side” (appeals) Judge Rymer concludes we permit premature filings because requiring refiling would be "silly.” Although the rule is not as simple as that, we are willing to accept her view that Keating’s habeas petition should be treated as prematurely filed and that it became “ripe” when our mandate issued. We adopt her position as an alternate holding on the jurisdictional question.
. We reject the state’s argument that granting habeas relief to Keating would violate Teague’s prohibition of reliance on rules adopted after a defendant’s conviction has become final. See Teague v. Lane, 489 U.S. 288, 109 S.Ct. 1060, 103 L.Ed.2d 334 (1989). It has long been clear that omission of an element of the offense from the jury instructions violates due process. The state’s argument rests on an erroneous interpretation of Teague — an interpretation that would preclude relief to any habeas petitioner unless the Supreme Court had decided a case involving identical facts, circumstances, and legal issues. Contrary to the slate's contention, it is not necessary that the Court have issued a decision that the failure to instruct on the particular element involved violates due process. For purposes of Teague, the Court's declaration of the general rule regarding a failure to instruct on an element of the offense is sufficient.
. The instruction was erroneous under the double jeopardy clause; the defendant had already pled guilty in juvenile court to the robbery offense. Slip op. at 4994, 4997 n. 2.
. Moreover, the fact that the jury did not have to find that Keating knew that the information that he conveyed to the bond sellers was false in order to convict him as a direct perpetrator, but did have to find criminal intent in order to convict him as an aider and abettor, would provide a plausible reason that some jurors might rely on the direct perpetrator instruction as a basis for conviction even if the other ground appears to be the more logical basis for liability.
.The state also argues that the California Court of Appeals made a factual finding that Keating had been convicted as an aider and *1064abettor rather than as a direct perpetrator, and that this finding must be afforded deference. However, the state court's conclusion that it was "obvious” that Keating could not be convicted as a direct perpetrator because he "was being tried on the theory that he aided and abetted in the sale of junk bonds,’ ” was not a finding of fact, but rather a determination that any error in instructing the jury on a direct perpetrator theory without giving Keating's requested instruction was harmless. We do not defer to a state court’s conclusion that a constitutional error was harmless, but instead review this question de novo. See Lawson v. Borg, 60 F.3d 608, 612 (9th Cir.1995); Dickson v. Sullivan, 849 F.2d 403, 405 (9th Cir.1988). Additionally, because the state court discussed the theory on which the jury relied in the context of rejecting Keating’s argument that there was insufficient evidence to justify a direct perpetrator instruction, its conclusion was dicta. See People v. Guiton, 4 Cal.4th 1116, 17 Cal.Rptr.2d 365, 847 P.2d 45, 50-53 (1993) (finding that one basis for a conviction is factually insufficient does not require reversal as long as there is a factually sufficient basis for the jury's verdict).
. Although the judge responded by expressing his disagreement with the prosecutor’s theory, he did not communicate this disagreement to the jury, and in fact instructed it that an "offer to sell” could include "every attempt to, or offer to dispose of ... a security” — an instruction that the prosecutor himself had interpreted as allowing Keating's conviction as the source of the offer. In the proposed jury instructions that it submitted prior to trial, the state had relied on this definition to argue that no "linkage or connection” need be shown "between a defendant 'offerer' and a victim buyer,” and argued that "the People are not obligated to prove direct and personal contact between each defendant and every victim.” People’s Proposed Liability Theory Jury Instructions at 26, 28.
. In fact, the district court concluded that "[a] reasonable reading of the prosecutor's closing argument makes the conclusion that he considered the aiding and abetting theory subsidiary to the direct perpetrator theory nearly inescapable.” Dist. Ct. Opinion at 25. In his closing argument, the prosecutor characterized Keating as responsible for every act of American Continental (stating that "Mr. Keating was the company”), utilized language that described Keating as "selling” the bonds, and employed analogies (of a drive-by shooter and a used car salesman) that were more suggestive of a direct perpetrator than an aider and abettor. The prosecutor emphasized that Keating was the source of the material omissions of information by comparing the flow of information at Lincoln and American Continental to an "hourglass,” explaining that Keating "controlled the flow of information downstream” through his "conduit” (a bank official who had more direct contact with the bond sellers) in a manner that caused the bond sellers to be unaware of the information suggesting that the bonds were a risky investment. In his opening argument, the prosecutor had similarly emphasized Keating’s direct responsibility for the material omissions and thereby suggested that he had acted as a direct perpetrator.
.Even were we to review the record for the purpose of determining whether, if Keating was convicted as a direct perpetrator, the omission of the mens rea element would be harmless, we would reach the same result. Although it is not readily apparent how to resolve the tension between the California v. Roy, 519 U.S. 2, 117 S.Ct. 337, 136 L.Ed.2d 266 (1996), and the Stromberg line of cases, under any of the possible approaches, the result would be the same. Under Roy, the most stringent approach, we would look first to the erroneous instruction regarding the direct perpetrator theory of liability, and determine whether a verdict of guilty under it would be harmless error. Unlike Neder, in which the defendant failed to contest the omitted element, here Keating vigorously challenged the state's evidence that pointed to his knowledge of the falsity or misleading nature of the information that was conveyed to the bond purchasers. Indeed, those attacks constituted Keating’s entire defense.
*1065While the evidence that was presented on that question would have been sufficient to support a conviction, the jury could also reasonably have concluded that a finding that Keating had the requisite criminal intent would require it to take too many inferential steps. We would therefore be left in "grave doubt” whether the jury would have convicted Keating as a direct perpetrator if required to find criminal intent. When "the matter is so evenly balanced that [a judge] finds himself in virtual equipoise as to the harmlessness of the error,” and the court is therefore left with a "grave doubt about the likely effect of an error on the jury’s verdict,” the error must be treated as if it were not harmless. O’Neal, 513 U.S. at 435, 115 S.Ct. 992. That, in our view, is the circumstance in which we find ourselves. We note that because the state did not raise the Roy question on appeal, a more extensive analysis of the facts and the law relevant to that question is not required.