
    Allen L. SCHAFER, Appellant, v. Dick MOORE; Gail Hughes; George A. Lombardi; Dale Riley; Myrna Trickey; Randee Kaiser; Cranston Mitchell; Paul D. Caspari; Janet Schneider; Ted Fertig; Jeanie Schneider Theis; Cameron Danniels; Jennifer Sasche; Barry Dolan; Mrs. Unknown Cook; Unknown Nash; Betty Day, Appellees.
    No. 92-3555.
    United States Court of Appeals, Eighth Circuit.
    Submitted Oct. 27, 1994.
    Decided Jan. 27, 1995.
    
      Allen L. Schafer, pro se.
    R. Henry Branom, Jr., St. Louis, MO, for appellee.
    Before WOLLMAN, Circuit Judge, JOHN R. GIBSON, Senior Circuit Judge, and BEAM, Circuit Judges.
   PER CURIAM.

Allen L. Schafer, a Missouri inmate, appeals the district court’s dismissal of his 42 U.S.C. § 1983 civil rights action for failure to state a claim. We affirm, but modify the district court’s order to a dismissal without prejudice.

I.

The relevant facts are undisputed. In 1980 the Missouri legislature enacted Mo.Rev.Stat. § 589.040.1 (1986) establishing the Missouri Sexual Offender Program (MOSOP) with its “ultimate goal [being] the prevention of future sexual assaults by the participants in such programs.” The 1980 statute further provided: “All persons imprisoned by the department of corrections and human resources for sexual assault offenses shall be required to participate in the programs developed pursuant to subsection 1 of this section.” Mo.Rev.Stat. § 589.040.2 (1986) (emphasis added). In 1990, the Missouri Legislature amended the MOSOP statute by substituting “successfully complete” for “participate in.” Mo.Rev.Stat. § 589.040.2 (Supp.1994).

Schafer alleged that in 1989 he pleaded guilty to rape and was sentenced to six years imprisonment. According to the complaint, even though Schafer participated in the MO-SOP, he was not paroled because he failed to complete the program. The complaint further stated that Schafer had unsuccessfully petitioned for state habeas relief. Relevant to this appeal, Schafer argued that application of the 1990 amendment to him violated the Ex Post Facto Clause of the Constitution and that the MOSOP statute constituted a bill of attainder. In addition to money damages, Schafer sought immediate release. Defendants moved to dismiss arguing, inter aha, that section 1983 relief was not available because Schafer was attacking the duration, and not a condition, of his confinement.

II.

We review de novo a district court’s dismissal of a complaint for failure to state a claim. See Ring v. First Interstate Mortgage, Inc., 984 F.2d 924, 926 (8th Cir.1993). Like the district court, we must view the complaint most favorably to Schafer and may dismiss “only if it is clear that no relief could be granted under any set of facts that could be proved consistent with the allegations.” Hishon v. King & Spalding, 467 U.S. 69, 73, 104 S.Ct. 2229, 2232, 81 L.Ed.2d 59 (1984).

Since the district court’s ruling, the Supreme Court in Heck v. Humphrey, — U.S. -, 114 S.Ct. 2364, 129 L.Ed.2d 383 (1994), held that, if a judgment in favor of a prisoner in a section 1983 action would necessarily imply the invalidity of his conviction, continued imprisonment, or sentence, then no claim for damages lies unless the conviction or sentence is reversed, expunged, or called into question by issuance of a writ of habeas corpus. Id. at-, 114 S.Ct. at 2372. The plain language of the complaint demonstrates Schafer is challenging the duration of his confinement, ie., if he were to prevail in his section 1983 suit, the result would necessarily imply the invalidity of his continued confinement. Therefore, in light of Heck, the complaint was properly dismissed for failure to state a claim. See Heck, — U.S. at-, 114 S.Ct. at 2372; Best v. Kelly, 39 F.3d 328, 330 (D.C.Cir.1994) (under Heck, 42 U.S.C. § 1983 unavailable for claims of unconstitutional deprivations of good time credits).

Although we affirm the district court’s order, we modify the dismissal to be without prejudice so that Schafer can refile his complaint should he succeed in challenging the legality of his continued confinement through appropriate state or federal remedies. See, e.g., Preiser v. Rodriguez, 411 U.S. 475, 499-500, 93 S.Ct. 1827, 1840-41, 36 L.Ed.2d 439 (1973) (inmate challenging duration of his physical imprisonment must exhaust state remedies and petition for writ of habeas corpus under 28 U.S.C. § 2254); Offet v. Solem, 823 F.2d 1256, 1257 (8th Cir.1987) (§ 2254, which requires exhaustion of state remedies, appropriate vehicle for state prisoners challenging length of confinement and seeldng restoration of good time credits).

We reject as meritless Schafer’s argument that the MOSOP statute constitutes a bill of attainder. A bill of attainder is “a legislative Act which inflicts punishment on named individuals or members of an easily ascertainable group without a judicial trial.” Ambassador Books & Video, Inc. v. City of Little Rock, 20 F.3d 858, 865 (8th Cir.) (quoting United States v. O’Brien, 391 U.S. 367, 383 n. 30, 88 S.Ct. 1673, 1683 n. 30, 20 L.Ed.2d 672 (1968)), cert. denied, — U.S. -, 115 S.Ct. 186, 130 L.Ed.2d 120 (1994). Because the MOSOP statute applies only to persons who have already been convicted of sex offenses, it cannot be classified as a bill of attainder. We decline to address those arguments Schafer raises for the first time on appeal. See Dorothy J. v. Little Rock Sch. Dist., 7 F.3d 729, 734 (8th Cir.1993).

Accordingly, in light of the foregoing, we affirm but modify the judgment to a dismissal without prejudice. 
      
      . The Honorable Clyde S. Cahill, Senior United States District Judge for the Eastern District of Missouri.
     