
632 So.2d 167 (1994)
Robert T. AVERA, Appellant,
v.
Tom L. BARTON, Superintendent, Florida State Prison, Appellee.
No. 92-03008.
District Court of Appeal of Florida, First District.
February 11, 1994.
Rehearing Denied March 21, 1994.
Robert T. Avera, pro se.
Judy Bone, Asst. General Counsel, Dept. of Corrections, Tallahassee, for appellee.
PER CURIAM.
This cause is on appeal from an order denying Robert T. Avera's petition for writ of habeas corpus. Avera raises two issues: (1) whether the trial court erred in failing to conduct an evidentiary hearing as previously ordered; and (2) whether the amount of basic gain time forfeited was the result of an ex post facto application of law. We need not *168 address the first issue because we find that Avera's argument as to the second issue requires us to reverse and remand to the trial court.
Appellant Avera is currently in custody of the Florida Department of Corrections (DOC), serving a sentence of 34 1/2 years. Avera originally began a 30-year sentence on September 14, 1979. On July r, 1981, Avera escaped from DOC custody and was recaptured the same day. That same year, Avera was convicted of escape and sentenced to an additional 15-year prison term.[1] In addition, DOC forfeited all gain time earned up to the date of the escape pursuant to section 944.28, Florida Statutes. In January 1984, the 15-year sentence was reduced to 4 1/2 years' imprisonment.
On July 24, 1990, Avera filed a petition for writ of habeas corpus in the Circuit Court in and for Bradford County. In his petition, Avera alleged that he was being illegally held because DOC improperly forfeited 277 days of basic gain time as a result of his escape conviction. Although unartfully worded, the petition asserted that DOC had calculated the amount of basic gain time forfeited by using revised section 944.275, Florida Statutes (1983). Avera argued that use of this statute was an ex post facto application of law, citing Waldrup v. Dugger, 562 So.2d 687 (Fla. 1990). The trial court summarily denied the petition.
On appeal, this court interpreted Avera's petition as alleging that DOC improperly revoked gain time earned after the date of his escape. Avera v. State, 582 So.2d 93 (Fla. 1st DCA 1991). On July 26, 1991, the court reversed the denial of the writ, finding that Avera alleged facts that, if true, would establish that DOC failed to comply with its own rules. Id. The court then remanded for an evidentiary hearing to determine whether Avera forfeited any gain time earned after the escape as a result of the escape. Id. at 94.
Instead of complying with the mandate of this court, the circuit court issued a show cause order to DOC as to why an evidentiary hearing should not be held. DOC responded, arguing that Avera was not entitled to the relief requested. DOC also submitted an affidavit explaining the method used to calculate the amount of gain time forfeited. The trial court summarily denied Avera's petition again and adopted DOC's calculations. Avera appealed.
In his brief, Avera again argues that using revised section 944.275, Florida Statutes (1983), to calculate the amount of basic gain time forfeited was an ex post facto application of law based on Waldrup v. Dugger, 562 So.2d 687 (Fla. 1990). He urges that DOC should have used section 944.275, Florida Statutes (1981), the statute in effect at the time of his escape and escape conviction.
In Waldrup, inmate Waldrup filed a petition for habeas corpus challenging the retroactive application of the 1983 revised gain-time statute. Specifically, Waldrup complained that the revised statute penalized him because it did not offer as much incentive gain time as the earlier version. The Supreme Court agreed and held that the retroactive application of the 1983 amended version of section 944.275, Florida Statutes, was ex post facto as applied to Waldrup. Here, Avera's novel argument asserts that DOC's use of the more generous version of the gain-time statute is ex post facto as applied to him because he forfeits a greater amount of basic gain time. We agree.
Two elements must be present in order for a criminal or penal law to be ex post facto: (1) the law must be retrospective, that is, it must apply to events occurring before *169 its enactment; and (2) the law must disadvantage the offender. Waldrup, 562 So.2d at 691; Weaver v. Graham, 450 U.S. 24, 29, 101 S.Ct. 960, 964, 67 L.Ed.2d 17, 23 (1981), citing, Lindsey v. Washington, 301 U.S. 397, 401, 57 S.Ct. 797, 799, 81 L.Ed. 1182, 1186 (1937). First, the legislature revised section 944.275, Florida Statutes, in 1983 by changing the formula for calculating both basic and incentive gain time. The revised statute provided that basic gain time be "computed on and applied to all sentences imposed for offenses committed on or after July 1, 1978." § 944.275(6)(a), Fla. Stat. (1983), (Ch. 83-131, § 8, Laws of Fla.); see Fla. Admin. Code R. 33-11.0035(1)(b). As a result, DOC retrospectively applied the revised version of section 944.275 to calculate the amount of basic gain time Avera earned prior to his escape. Second, under the 1983 version of section 944.275, basic gain time is calculated as follows:
(4)(a) As a means of encouraging satisfactory behavior, the department shall grant basic gain time at the rate of 10 days for each month of each sentence imposed on a prisoner... .
§ 944.275, Fla. Stat. (1983). Here, DOC calculated Avera's gain time by first establishing a percentage of days served by dividing the days served up to the escape (842) by the total days in a 30-year sentence (10,950). DOC then multiplied that percentage (7.69 percent) by the total amount of eligible days of gain time in a 30-year sentence (3600).[2] That totaled the 277 days of basic gain time forfeited. At the time of Avera's escape and corresponding conviction, basic gain time was calculated under section 944.275 as follows:
(1)(a) Three days per month off the first and second years of the sentence;
(b) Six days per month off the third and fourth years of the sentence; and
(c) Nine days per month off the fifth and all succeeding years of the sentence; and the prisoner shall be entitled to credit for a month as soon as the prisoner has served such time as, when added to the deduction allowable, would equal a month.
§ 944.275, Fla. Stat. (1981). The amount of gain time forfeited by Avera under this version of the statute is the amount of basic gain time days earned per 12-month period for 28 months, the amount of time served prior to escape. Under our calculations, Avera's basic gain time forfeited would be 96 days, far less than the 277 days asserted by DOC. Thus, the use of the revised version of section 944.275 was disadvantageous to Avera. Having satisfied both elements of an ex post facto application of law, the use of the revised statute to calculate gain time forfeited was improper as applied to Avera.
Although Avera is entitled to some relief, it cannot be through a habeas corpus petition because Avera has not established the right to be released from prison. He has only established a right to have his basic gain time forfeited recomputed in light of this ex post facto analysis. However, mandamus will lie when such a right and duty exist. Waldrup v. Dugger, 562 So.2d 687 (Fla. 1990); Moore v. Florida Parole and Probation Commission, 289 So.2d 719 (Fla.), cert. denied, 417 U.S. 935, 94 S.Ct. 2649, 41 L.Ed.2d 239 (1974). Accordingly, the court will treat Avera's petition as a request for writ of mandamus and grant the writ.
In sum, we reverse and remand for a redetermination of basic gain-time forfeited by Avera up to the point of his escape under the formula in effect in 1981. We also note for remand that nothing requires DOC to recalculate gain time using the "percentage method." A review of the rule in effect in 1981 indicates that "gain time will be awarded or withheld monthly." (emphasis added). Fla. Admin. Code R. 33-11.045.
BOOTH, SMITH and WEBSTER, JJ., concur.
NOTES
[1]  There is conflicting evidence in the record as to exactly when Avera was convicted of the escape. Avera asserts in his request for administrative remedy that his conviction for escape was in October 1981. DOC asserts in its affidavit that Avera was convicted of the escape on September 14, 1981. Either way, it appears to have been in 1981. The prior opinion of this court, however, erroneously lists Avera's conviction for escape as 1984, not 1981. Although the doctrine of law of the case generally precludes reconsideration of a legal issue decided in a previous appeal in the same case, it does not divest the appellate court of its inherent power to correct a prior ruling that was erroneous. Padovano, Florida Appellate Practice, § 14.12. This is especially true here, where the date of conviction was an erroneous recitation of fact and not an issue of law argued by either side.
[2]  We presume that the percentage method is based on the current version of Florida Administrative Code Rule 33-11.0045(3), which states in part that "[b]asic gain time shall be calculated at the rate specified by law according to the date of offense and shall be based on the length of the sentence imposed." (emphasis added).
