                 FOR PUBLICATION
 UNITED STATES COURT OF APPEALS
      FOR THE NINTH CIRCUIT

DAVID LEON STOKES, II,                    No. 04-16454
             Petitioner-Appellant,
               v.                           D.C. No.
                                         CV-03-01537-NVW
DORA B. SCHRIRO, Director,
                                             OPINION
            Respondent-Appellee.
                                     
       Appeal from the United States District Court
                for the District of Arizona
         Neil V. Wake, District Judge, Presiding

                 Argued and Submitted
       October 18, 2005—San Francisco, California

                  Filed October 6, 2006

  Before: Dorothy W. Nelson, Johnnie B. Rawlinson, and
              Carlos T. Bea, Circuit Judges.

               Opinion by Judge Rawlinson




                          17433
                     STOKES v. SCHRIRO                17435


                        COUNSEL

Jon M. Sands, Federal Public Defender, and Jennifer Y. Gar-
cia, Assistant Federal Public Defender, Tucson, Arizona, for
appellant David Leon Stokes, II.
17436                 STOKES v. SCHRIRO
Terry Goddard, Arizona Attorney General, Randall M. Howe,
Chief Counsel, Criminal Appeals Section, and Cari
McConeghy-Harris, Assistant Attorney General, Criminal
Appeals Section, Phoenix, Arizona, for appellee Dora B.
Schriro.


                         OPINION

RAWLINSON, Circuit Judge:

   A jury found David Leon Stokes, II (Stokes) guilty of
attempted kidnapping and attempted robbery in Arizona state
court. The jury also found the offenses to be “dangerous.” At
sentencing, the trial judge opted to sentence Stokes to twenty
years as a repetitive offender whose previous convictions
were for non-dangerous offenses. The judge then enhanced
the sentence to twenty-five years by finding aggravating cir-
cumstances. After Stokes’s habeas petition was denied in dis-
trict court, we granted a certificate of appealability (COA) on
the issue of whether Stokes “was sentenced in violation of the
Sixth Amendment pursuant to Apprendi v. New Jersey, 530
U.S. 466 (2000), because the trial court disregarded the jury’s
findings of dangerousness and sentenced appellant as a non-
dangerous repetitive offender.” We conclude that the trial
court’s election of one statutory sentencing option over
another was not contrary to Apprendi. However, the court ran
afoul of Apprendi when it relied on judicial factfinding to
increase Stokes’s sentence beyond the statutory maximum.
Accordingly, we affirm in part, reverse in part, and remand.

                               I

    FACTUAL AND PROCEDURAL BACKGROUND

   In May 1999, the Milners pulled their car into a conve-
nience store parking lot. Mr. Milner went into the store while
                            STOKES v. SCHRIRO                       17437
Mrs. Milner remained in the car. Stokes entered the car,
grabbed Mrs. Milner’s neck, threatened her with a “blade,”
and told her he was going to steal the car. Mrs. Milner
grabbed the keys from the ignition and jumped out of the car,
but not before Stokes slashed her neck with the “blade.” Mrs.
Milner survived, and Stokes was eventually apprehended.

   An Arizona state jury subsequently found Stokes guilty of
attempted kidnapping and attempted robbery, both class three
felonies. The jury also found the offenses for which Stokes
was convicted to be “dangerous.”

   Stokes’s sentencing presented the Arizona state judge with
two options. Because this was Stokes’s first conviction for a
dangerous felony, the judge could sentence Stokes as a first-
time dangerous offender under Arizona Revised Statute § 13-
604(I), for a maximum sentence of fifteen years.1 In the alter-
native, and in view of Stokes’s prior convictions for at least
two non-dangerous felonies, the judge could sentence Stokes
as a repetitive offender whose previous convictions were for
non-dangerous offenses. Under Arizona Revised Statute § 13-
604(D), the maximum sentence under the latter option was
twenty years.2

  The judge elected the latter option after finding that Stokes
  1
   Subsection 13-604(I) stated:
      [U]pon a first conviction of a class 2 or 3 felony involving dis-
      charge, use or threatening exhibition of a deadly weapon or dan-
      gerous instrument or upon conviction of a class 2 or 3 felony
      when the intentional or knowing infliction of serious physical
      injury upon another has occurred, the defendant shall be sen-
      tenced to imprisonment as prescribed in this subsection . . .
Ariz. Rev. Stat. Ann. § 13-604(I) (1999).
  2
    Subsection 13-604(D) stated that “a person who . . . stands convicted
of a class 2 or 3 felony, and who has two or more historical prior felony
convictions, shall be sentenced to imprisonment as prescribed in this sub-
section . . .” Ariz. Rev. Stat. Ann. § 13-604(D) (1999).
17438                       STOKES v. SCHRIRO
had been convicted of driving under the influence, theft, and
possession of a narcotic drug. The judge then enhanced the
twenty-year sentence to twenty-five years under Arizona
Revised Statute § 13-702(C) and § 13-702.01(E) by finding
three aggravating circumstances: (1) “physical and emotional
harm to the victim,” (2) “the defendant was previously con-
victed of felonies within 10 years immediately preceding the
date of this offense,” and (3) “defendant’s 1981 convictions
for kidnapping and aggravated assault . . . are strikingly simi-
lar to the instant offenses.”3 The judge ultimately sentenced
Stokes to two “super-aggravated” terms of twenty-five years
to be served concurrently.

   Stokes appealed to the Arizona Court of Appeals, asserting,
inter alia, that his sentence was “unlawful” because the jury
found that his offenses were dangerous, yet the judge disre-
garded the jury’s findings and instead sentenced him as a non-
dangerous repetitive offender, resulting in a longer sentence.

  Relying on State v. Smith, 828 P.2d 778 (Ariz. Ct. App.
1992), the Court of Appeals rejected Stokes’s argument. The
Court of Appeals reasoned that Smith, which addressed an
almost identical scenario, recognized the judge’s discretion to
sentence under either subsection. Stokes’s appeal to the Ari-
zona Supreme Court was denied.4

   Stokes requested post-conviction relief on a basis other
than his unlawful sentence claim. His request and petitions for
review were denied.
   3
     Subsection 13-702(C) listed a number of aggravating circumstances
that “the court shall consider.” Ariz. Rev. Stat. Ann. § 13-702(C) (1999).
   Subsection 13-702.01(E) stated: “[I]f a person is convicted of a felony
offense and has two or more historical prior felony convictions and if the
court finds that at least two substantial aggravating factors listed in section
13-702, subsection C apply, the court may increase the maximum term of
imprisonment . . .” Ariz. Rev. Stat. Ann. § 13-702.01(E) (1993).
   4
     During the course of Stokes’s direct appeal, the United States Supreme
Court decided Apprendi.
                           STOKES v. SCHRIRO                         17439
   Stokes then petitioned for a writ of habeas corpus under 28
U.S.C. § 2254 in federal district court. Citing Apprendi, he
again argued that his sentence was unlawful because the judge
disregarded the jury’s findings of dangerousness and opted to
sentence him as a non-dangerous repetitive offender.

   The magistrate judge recommended that the district court
deny Stokes’s petition. The district court accepted the magis-
trate judge’s recommendation and concluded that Stokes was
not sentenced in violation of Apprendi under the sentencing
statutes as construed by the Arizona state courts.

   The district court denied Stokes’s request for a COA. How-
ever, we granted a COA on the issue of “whether appellant
was sentenced in violation of the Sixth Amendment pursuant
to Apprendi v. New Jersey, 530 U.S. 466 (2000), because the
trial court disregarded the jury’s findings of dangerousness
and sentenced appellant as a non-dangerous repetitive offend-
er.”5
   5
     On appeal, Stokes raises two uncertified issues: (1) whether the trial
court violated Apprendi by finding the fact of his prior convictions to
enhance his sentence; and (2) whether the trial court violated Apprendi by
enhancing his sentence based on a judicial finding of aggravating circum-
stances. We treat Stokes’s opening brief raising these uncertified issues as
a request to expand the COA. See Solis v. Garcia, 219 F.3d 922, 926 (9th
Cir. 2000) (per curiam).
   We deny Stokes’s request to expand the COA to include the prior con-
victions issue because he has not made a “substantial showing of the
denial of a constitutional right[.]” Id. (citation omitted). In Apprendi, the
Supreme Court expressly held, “[o]ther than the fact of a prior conviction,
any fact that increases the penalty for a crime beyond the prescribed statu-
tory maximum must be submitted to a jury . . .” 530 U.S. at 490 (emphasis
added). That is, prior convictions are an exception to the Apprendi rule.
See United States v. Weiland, 420 F.3d 1062, 1079 & n.16 (9th Cir. 2005),
cert. denied, 126 S. Ct. 1911 (2006). Accordingly, the trial court’s find-
ings of prior convictions to enhance Stokes’s sentence did not contravene
Apprendi.
   However, we grant Stokes’s request to expand the COA to include the
issue of whether the trial court violated Apprendi by enhancing his sen-
tence based on a judicial finding of aggravating circumstances. On this
issue, Stokes has made a “substantial showing of the denial of a constitu-
tional right[.]” Solis, 219 F.3d at 926 (citation omitted).
17440                      STOKES v. SCHRIRO
                                     II

                             DISCUSSION

   We review a district court’s decision to deny a habeas peti-
tion de novo and its findings of fact for clear error. Fowler v.
Sacramento County Sheriff’s Dep’t, 421 F.3d 1027, 1034 (9th
Cir. 2005). Because Stokes filed his petition after April 24,
1996, it is governed by the Antiterrorism and Effective Death
Penalty Act of 1996 (AEDPA). Id.

   To obtain habeas relief under AEDPA, Stokes must show
that the relevant state court decision “was contrary to, or
involved an unreasonable application of, clearly established
Federal law, as determined by the Supreme Court of the
United States.” 28 U.S.C. § 2254(d)(1).

    “[A] decision is contrary to clearly established federal law
. . . if the state court applies a rule that contradicts the govern-
ing law set forth in the Supreme Court’s cases or if the state
court confronts a set of facts that are materially indistinguish-
able from a decision of the Supreme Court and nevertheless
arrives at a result different from that precedent.” Fowler, 421
F.3d at 1034-35 (citation, alterations, and internal quotation
marks omitted).

   “[C]learly established Federal law, as determined by the
Supreme Court” refers to Supreme Court precedent at the
time of the last-reasoned state court decision.6 Id. at 1034.
   6
     The last-reasoned state court decision for Stokes’s claim regarding the
judge’s act of disregarding the jury’s findings of dangerousness is the
Court of Appeals’s July 20, 2000 memorandum decision. This is the last-
reasoned state court decision because the state supreme court denied
review on direct appeal without comment. The subsequent “minute entry”
denying Stokes’s petition for post-conviction relief did not address the
unlawful sentence issue, as Stokes did not raise it in his petition for post-
conviction relief.
                           STOKES v. SCHRIRO                         17441
  A.    The judge did not violate Apprendi by opting to
        sentence Stokes as a repetitive offender whose
        previous convictions were for non-dangerous
        offenses.7

   According to Stokes, the Court of Appeals’s memorandum
decision affirming the judge’s sentencing order is contrary to
Apprendi in the following way: The jury found Stokes’s
offenses to be dangerous. Under § 13-604(I) (the first-time
dangerous offender statute), the judge could only impose a
sentence of fifteen years. However, the judge opted to sen-
tence Stokes as a repetitive offender whose previous convic-
tions were for non-dangerous offenses. Under § 13-604(D)
(the repetitive offender statute), the judge sentenced Stokes to
twenty years (not counting the additional five-year enhance-
ment based on aggravating circumstances).

   [1] Apprendi was violated, Stokes argues, when the judge
disregarded the jury’s findings of dangerousness and exposed
him to a sentence greater than that allowed by the jury’s ver-
dicts. The jury’s verdicts were sufficient to expose Stokes to
a twenty-year sentence, however. In disregarding the danger-
ousness finding, the judge did not negate that finding. Instead,
the existence or nonexistence of the crime’s dangerousness
was irrelevant to the application of § 13-604(D), which

   With respect to the propriety of the judge’s findings of aggravating cir-
cumstances, however, there is no last-reasoned state court decision.
Accordingly, we “perform an independent review of the record to ascer-
tain whether the state court decision was objectively unreasonable.” Pham
v. Terhune, 400 F.3d 740, 742 (9th Cir. 2005) (per curiam) (citation and
internal quotation marks omitted).
   7
     Even though Apprendi was decided after the sentencing order,
Apprendi nevertheless constitutes applicable, controlling federal law for
purposes of this appeal. Because “Apprendi was decided while [Stokes’s]
case was still on direct review[,] . . . the rule announced in Apprendi can
be asserted by [Stokes] in a § 2254 petition.” Schardt v. Payne, 414 F.3d
1025, 1035 n.10 (9th Cir. 2005) (citation omitted).
17442                  STOKES v. SCHRIRO
requires only that the defendant have previous non-dangerous
convictions. See, e.g., State v. Sammons, 749 P.2d 1372, 1376
(Ariz. 1988) (regarding as “mere surplusage” under § 13-
604D a finding that the current offense was dangerous);
Smith, 828 P.2d at 780 (holding that § 13-604(D) applied
“[b]ecause [defendant’s] prior convictions were for non-
dangerous felonies”). Accordingly, under Arizona law the
applicable statutory maximum was the greater of those pro-
vided by §§ 13-604(D) and 13-604(I). See Sammons, 749 P.2d
at 1376 (considering the greater of the two a proper “sentenc-
ing option selected by the trial court”); Smith, 828 P.2d at 780
(same); cf. State v. Quinonez, 976 P.2d 267, 270 (Ariz. Ct.
App. 1999) (holding in a similar situation that “the only sen-
tencing range that applied in this case was . . . the more severe
one”).

   [2] Contrary to Stoke’s arguments, the Arizona state courts’
interpretation of these provisions does not contradict any
clearly established federal law. A statutory maximum need
not be defined by every one of the facts found at trial, so long
as the defendant is not “expose[d] . . . to a greater punishment
than that authorized” solely by those facts (or the fact of a
prior conviction). Apprendi, 530 U.S. at 490, 494. The appli-
cation of § 13-604(D) did not depend on any fact that was not
submitted to the jury, other than the facts of Stokes’s prior
convictions. See id. at 490. Because the twenty-year sentence
was authorized by the jury’s findings, no Apprendi violation
occurred. See United States v. Sua, 307 F.3d 1150, 1154 (9th
Cir. 2002). Stokes is therefore not entitled to habeas relief on
this claim.

  B.    The judge violated Apprendi by enhancing Stokes’s
        sentence based on aggravating circumstances found
        by the judge.

   The sentencing judge enhanced Stokes’s sentence by find-
ing three aggravating circumstances: (1) “physical and emo-
tional harm to the victim,” (2) “the defendant was previously
                            STOKES v. SCHRIRO                         17443
convicted of felonies within 10 years immediately preceding
the date of this offense,” and (3) “defendant’s 1981 convic-
tions for kidnapping and aggravated assault . . . are strikingly
similar to the instant offenses.” These findings enhanced
Stokes’s sentence to twenty-five years, beyond the prescribed
statutory maximum of twenty years. Because these findings
were not made by a jury, the sentence violated applicable fed-
eral law. See Apprendi, 530 U.S. at 490-92.8

   [3] The judge’s findings of aggravating circumstances are
not covered by Apprendi’s prior conviction exception. Even
if the prior conviction exception covers the finding that “the
defendant was previously convicted of felonies within 10
  8
   This conclusion is reinforced by the legislative activity surrounding
§ 13-702(C) and § 13-702.01(E), the applicable sentencing statutes, both
of which were amended in 2005.
   Pre-2005, § 13-702(C) stated that “the court shall consider the follow-
ing aggravating circumstances[.]” Ariz. Rev. Stat. Ann. § 13-702(C)
(1999) (emphasis added). As amended, this subsection now states that “the
trier of fact shall determine and the court shall consider the following
aggravating circumstances[.]” Ariz. Rev. Stat. Ann. § 13-702(C) (2005)
(emphasis added).
   Similarly, pre-2005, § 13-702.01(E) stated: “[I]f a person is convicted
of a felony offense and has two or more historical prior felony convictions
and if the court finds that at least two substantial aggravating factors . . .
apply, the court may increase the maximum term of imprisonment . . .”
Ariz. Rev. Stat. Ann. § 13-702.01(E) (1993) (emphasis added). As
amended, the subsection stated: “[I]f a person is convicted of a felony
offense and has two or more historical prior felony convictions and if the
trier of fact finds beyond a reasonable doubt that at least two aggravating
factors . . . apply, the court may increase the maximum term of imprison-
ment . . .” Ariz. Rev. Stat. Ann. § 13-702.01(E) (2005) (emphasis added).
The legislature also added subsection (J), which states that “ ‘trier of fact’
means a jury.” Id. § 13-702.01(J). Further amendments in 2006 preserved
these changes, in effect. See 2006 Ariz. Legis. Serv. Ch. 148 (West).
   Under the current statutes, aggravating factors are to be found by a jury
beyond a reasonable doubt, and not by the court. This change, as well as
the revision to § 13-702(C), indicates that the legislature recognized that
the pre-2005 versions used by the judge in this case were problematic.
17444                  STOKES v. SCHRIRO
years immediately preceding the date of this offense,” neither
of the other two findings is covered by the exception because
each was directed at Stokes’s present offenses, not the fact of
his prior offenses.

   [4] The judge found that there was “physical and emotional
harm to the victim.” This finding, directed at the present
offenses, is not covered by the prior conviction exception. See
United States v. Matthews, 312 F.3d 652, 664 (5th Cir. 2002)
(holding that the judge violated Apprendi when he enhanced
the defendant’s sentence by finding that the defendant com-
mitted his offenses (1) while participating in a criminal street
gang with knowledge of its criminal activities and (2) with
intent to promote criminal activities or to maintain or increase
his position in the gang because those findings were “unre-
lated to the fact of a prior conviction, but directly related to
the current charged offense.”) (emphasis added).

   [5] The judge also found that Stokes’s “1981 convictions
for kidnapping and aggravated assault . . . are strikingly simi-
lar to the instant offenses.” This finding similarly focuses on
the present offenses as a basis of comparison to past offenses
and is beyond the scope of the prior conviction exception. See
United States v. Kortgaard, 425 F.3d 602, 608-09 (9th Cir.
2005) (holding that the sentence enhancement violated the
defendant’s Sixth Amendment right to a jury trial because the
findings that trigger the enhancement “do not follow necessar-
ily from the fact of any prior conviction or sentence but
instead call for the judgment of a factfinder.”).

   [6] Because the prior conviction exception does not inocu-
late an enhancement predicated upon judicial factfinding,
Stokes’s sentence violated Apprendi. See Apprendi, 530 U.S.
at 490-92. Where a court imposes a sentence beyond the stat-
utory maximum, the government has the burden of showing
that the error was harmless beyond a reasonable doubt. See
United States v. Banuelos, 322 F.3d 700, 706 and n.4 (9th Cir.
                       STOKES v. SCHRIRO                    17445
2003). As the government failed to meet its burden, Stokes is
entitled to habeas relief on this claim.

                               III

                       CONCLUSION

  [7] The district court correctly concluded that the Arizona
Court of Appeals’s decision upholding Stokes’s enhanced
sentence as a repetitive offender was not contrary to
Apprendi. However, the sentencing judge committed
Apprendi error when he used judicial findings to enhance
Stokes’s sentence. Because the government failed to show
that the Apprendi error was harmless, Stokes is entitled to
habeas relief on that claim. Accordingly, we affirm in part,
reverse in part, and remand for the district court to grant the
habeas petition as to the imposition of the sentence enhance-
ment predicated upon judicial factfinding.

 AFFIRMED         in   part;   REVERSED        in   part;    and
REMANDED.
