
69 So.3d 951 (2010)
In re COMMITMENT OF Larry PHILLIPS.
Larry Phillips, Petitioner,
v.
State of Florida, Respondent.
No. 2D10-240.
District Court of Appeal of Florida, Second District.
Rehearing Denied February 9, 2011.
December 1, 2010.
*952 Kathleen A. Smith, Public Defender, and Richard R. Donnelly, Assistant Public Defender, Cape Coral, for Petitioner.
Bill McCollum, Attorney General, Tallahassee, and Joseph H. Lee, Assistant Attorney General, Tampa, for Respondent.
PER CURIAM.
Larry Phillips, a detained person under the Involuntary Civil Commitment of Sexually Violent Predators Act[1] (the Act) who is currently awaiting trial on the commitment petition, seeks a writ of prohibition to prevent the circuit court of Collier County from conducting further proceedings on the commitment petition. He asserts that the circuit court does not have jurisdiction to adjudicate the commitment petition filed under the Act because he was not in lawful custody at the time that proceedings under the Act were commenced. We agree that Phillips is entitled to relief on this basis.[2]
The facts of the case are not in dispute. In February 1990 Phillips was arrested on a fugitive warrant in Georgia and extradited to Collier County where he was charged with three counts of committing a lewd and lascivious assault. After posting bond in Florida, Phillips was returned to Georgia for prosecution of a separate offense. In July 1990 a Georgia court sentenced Phillips to three years in prison followed by seventeen years of probation for that offense. Phillips was paroled in March 1992 and returned to Florida to resolve the Collier County case.
In April 1992 the Collier County circuit court sentenced Phillips to two years in prison followed by ten years of probation. The court awarded Phillips two years of credit for the time he had served in Georgia prior to his return to Florida. This effectively erased the two-year prison sentence, and Phillips was processed in and out of the Florida Department of Corrections (DOC) on the same day that he was sentenced. Phillips thereafter returned to Georgia to serve both his Georgia and Florida probationary terms.
Less than two years later, Phillips violated both his Georgia probation and his Florida probation by committing a new law offense in Georgia. A Georgia court revoked his probation and sentenced him to prison. In January 2004 Phillips was paroled from prison in Georgia and extradited to Florida to face the violation of probation charge in Collier County. Phillips admitted to violating his Florida probation, and the court sentenced him to 5.5 years in prison with 177 days of jail credit. Less than a year later, Phillips filed a motion to correct illegal sentence pursuant to Florida Rule of Criminal Procedure 3.800(a). Phillips requested that a Florida postconviction court award him credit against his prison sentence for the two years of credit for time served in Georgia that the Florida *953 court had awarded in 1992. In September 2005 the postconviction court granted the motion and ordered the DOC to award Phillips the original jail and prison credit in addition to the credit for the 177 days he spent in custody prior to the revocation of his probation.
On December 6, 2005, Phillips was released from the DOC and was transferred to the Florida Civil Commitment Center pursuant to section 394.9135(1), Florida Statutes (2005).[3] The Department of Children and Family Services placed a seventy-two hour hold on Phillips and began its evaluation to determine whether he met the criteria for commitment as a sexually violent predator under the Act.[4] The multidisciplinary team timely recommended civil commitment to the state attorney, who filed a commitment petition.
In December 2008 the Florida Supreme Court issued its decision in Larimore v. State, 2 So.3d 101, 105 (Fla.2008), in which it held a person must be in lawful custody when commitment proceedings are initiated for the circuit court to have jurisdiction to adjudicate a commitment petition under the Act. In June 2009 Phillips, who was still in custody but had not been to trial, filed a motion to dismiss the commitment petition in the circuit court. Phillips argued that he was not in lawful custody at the time commitment proceedings were initiated on December 6, 2005, because his sentence had expired on August 31, 2005, based on the postconviction court's determination of entitlement to two years of prison credit against Phillips' sentence of 5.5 years. Phillips relied on an affidavit executed by a DOC administrator which stated that, with the application of the prior prison and jail credit, Phillips' sentence expired on August 31, 2005. The DOC included the award of 420 days of basic gain time and 234 days of incentive gain time in making this calculation.[5]
The circuit court denied the motion to dismiss based on its determination that Phillips was in lawful custody when commitment proceedings were initiated because "[t]he time period from August 31, 2005 to December 6, 2005 was well within the legal term of [Phillips'] sentence of 5 1/2 years." Phillips then filed this petition for writ of prohibition contending that because his sentence legally expired on August 31, 2005, he was not in lawful custody when commitment proceedings were initiated in December 2005. Phillips contends that, under Larimore, the circuit court is without jurisdiction to adjudicate the commitment petition.
Larimore involved a guilty plea to lewd and lascivious acts on a child in two separate cases in 1991. 2 So.3d at 104. Larimore was sentenced to fifteen years in prison in one case followed by five years of probation in the second case. He was released from prison in 1998 due to a gain *954 time award, and he began serving his probation. The court revoked Larimore's probation in February 2000 and sentenced him to five years in prison.
In August 2002 the First District Court of Appeal determined that Larimore was entitled, pursuant to Tripp v. State, 622 So.2d 941 (Fla.1993), to credit against the five-year prison sentence for the time served on the fifteen-year sentence imposed in the first case, including actual prison time and gain time. Larimore, 2 So.3d at 104. The award of credit would have effectively erased the five-year sentence imposed for the violation of probation, but the DOC forfeited 2830 days of gain time Larimore had earned on his fifteen-year prison sentence. Id.
In November 2004, while Larimore was in prison, the State filed a petition for involuntary civil commitment pursuant to the Act. Less than one month later, the First District held that Larimore was entitled to immediate release from custody because the DOC's forfeiture of his gain time was unauthorized. Id. (citing Larimore v. Fla. Dep't of Corr., 910 So.2d 847 (Fla. 1st DCA 2004)). Larimore then filed a motion to dismiss the commitment petition on the ground that he was not in lawful custody on the effective date of the Act. After the circuit court denied his motion, he filed a petition for writ of prohibition in the First District to prevent further proceedings against him under the Act. The First District denied the petition. 2 So.3d at 104 (citing Larimore v. State, 917 So.2d 354, 355 (Fla. 1st DCA 2005)).
On review of the denial of Larimore's petition for writ of prohibition, the supreme court held that Larimore was entitled to release because he "was not in legal custody when initial steps were taken to initiate civil commitment proceedings against him." Id. at 117. The court noted that it had previously construed the term "custody" to mean "lawful custody" in State v. Atkinson, 831 So.2d 172, 174 (Fla. 2002), in which it held that the Act was not applicable to individuals who were not in lawful custody on its effective date. Larimore, 2 So.3d at 115. The court explained that
interpreting the Jimmy Ryce Act as not requiring lawful custody for individuals who had been incarcerated at some point after the effective date of the Act but are not in lawful custody when commitment proceedings are initiated would be contrary not only to the overall intent of the Act but "would be contrary to the basic tenets of fairness and due process."
Id. (quoting Atkinson, 831 So.2d at 174).
This court recently applied Larimore under circumstances similar to those in this case. See Bishop v. Sheldon, 68 So.3d 259 (Fla. 2d DCA 2010). In Bishop the petitioner's original sentence had been imposed pursuant to sentencing guidelines which were subsequently declared illegal by the supreme court. Id. at 952. The petitioner's sentence was corrected by a postconviction court, and Bishop was entitled to immediate release because his sentence had expired. However, the petitioner was not released, and the State filed a petition for commitment under the Act. The petitioner sought a writ of habeas corpus in this court arguing that, under Larimore, the Act did not apply to him because he was not in lawful custody at the time commitment proceedings were initiated. Id. at 952-53. This court agreed that Larimore applied but transferred the case to the circuit court to resolve factual disputes over whether the petitioner was in lawful custody when commitment proceedings were initiated. Id. at 955.
This case requires a similar legal analysis but does not involve any disputed facts. Under Larimore, Phillips cannot be *955 committed pursuant to the Act if he was not in lawful custody when the State initiated commitment proceedings. Phillips' prison sentence of 5.5 years for the violation of his probation was illegal because the court failed to award prior jail and prison credit. See Haines v. State, 851 So.2d 831, 832 (Fla. 1st DCA 2003). After the postconviction court determined that the prior prison and jail credits should be applied to correct the illegal sentence, the DOC recalculated Phillips' sentence and found that it had expired as of August 31, 2005. Thus, Phillips was not in lawful custody when the State initiated commitment proceedings in December 2005. Cf. Atkinson, 831 So.2d at 174 (holding that defendant who was resentenced because his prior sentence had been imposed pursuant to unconstitutional sentencing guidelines was not in lawful custody when his sentence expired).
We recognize that section 394.9135 provides a procedure for the DOC to initiate commitment proceedings under the Act when the release of an inmate convicted of a qualifying offense "becomes immediate for any reason." However, this "`safety valve'" does not apply because lawful custody is required before the State may initiate commitment proceedings. Larimore, 2 So.3d at 105, 117 (quoting Gordon v. Regier, 839 So.2d 715, 719 (Fla. 2d DCA 2003)). Thus, even though Phillips' release became immediate upon his resentencing by the postconviction court, section 394.9135 was inapplicable. Id.
In its response to Phillips' petition the State argues that Phillips' reliance on Larimore is misplaced based on a footnote in Larimore in which the court stated as follows:
In this case, Larimore's entire resentencing was unlawful. Thus, we do not reach the question of whether section 394.9135, Florida Statutes, would allow the State to take steps to initiate a commitment proceeding against a person who while in lawful custody obtains an order for immediate release for any reason. That issue is not before us.
2 So.3d at 117 n. 8. The State claims that Phillips was in lawful custody because his sentence for the violation of probation was legal except that the gain time award was "incorrect." This argument is specious because the petitioner in Larimore was entitled to immediate release due to a misapplication of gain time. See also Madison v. State, 27 So.3d 61, 63 (Fla. 1st DCA 2009) (relying on Larimore to remand for the circuit court to consider gain time and other credits in determining whether Madison was in lawful custody at the time commitment proceedings were initiated).
The State alternatively argues that incentive gain time should not be considered in determining whether Phillips was in lawful custody at the time commitment proceedings were initiated. The State contends that if only basic gain time had been awarded, then Phillips would have been in lawful custody when commitment proceedings were commenced. However, the State has pointed to no authority to support its contention that basic and incentive gain time should be treated differently.
Under section 944.275(4)(b), Florida Statutes (1989),[6] incentive gain time "shall be credited and applied monthly." In September 2005, when the postconviction court ordered that Phillips receive credit against the sentence imposed *956 upon revocation of probation for the time previously served in prison, he had already been awarded incentive gain time. Both basic and incentive gain time become vested rights once awarded, subject to all other applicable statutory conditions. Waldrup v. Dugger, 562 So.2d 687, 694 (Fla. 1990); Davis v. Singletary, 659 So.2d 1126, 1127 n. 3 (Fla. 2d DCA 1995). Thus, the incentive gain time already earned and calculated is properly included in determining whether Phillips was lawfully in custody at the time of the commencement of commitment proceedings.
We appreciate the dissent's acknowledgement of our attempt "to remain obedient to the supreme court's precedent in Larimore and Atkinson." However, we do not share the dissent's view that the facts of this case may be distinguished from that supreme court precedent. First, there is no evidence in our record that Phillips intentionally delayed action in order to deprive the Department of Children and Family Services of jurisdiction. In fact, as the dissent recognizes, Phillips appropriately filed a motion to correct his sentence months before his legal sentence expired, but the postconviction court did not resolve the motion for nearly six months. Second, we are unable to agree with the dissent's position that Larimore and Atkinson should not apply because the circuit judge, Phillips' attorney, and the prosecutor were not conversant with the applicable sentencing law. Any such misunderstanding or confusion does not turn an illegal sentence into a legal sentence. Finally, the dissent suggests that defense counsel "is well advised to assure there is an unpreserved error in jail or prison credit" so that the defendant can delay correction of the error until it is too late to initiate commitment proceedings. The documents before us do not suggest this occurred in the present case. Moreover, while defense attorneys must zealously represent their clients, they must also fulfill their duty of candor towards the courts and must avoid conduct that undermines the integrity of the process. See R. Regulating Fla. Bar 4-3.3 cmt. Ultimately, though, it is the responsibility of judges and prosecutors to ensure that legal sentences are imposed and that errors are timely corrected.
Based on the gain time awarded and the application of prior prison credit in this case, Phillips' custodial sentence legally expired on August 31, 2005, well before the State initiated commitment proceedings in December 2005. Because Phillips was not in lawful custody at the time that proceedings under the Act were commenced, the circuit court does not have jurisdiction to adjudicate the commitment petition filed against Phillips under the Act. We therefore grant Phillips's petition for writ of prohibition and dismiss the State's commitment petition with prejudice. Phillips shall be immediately released from any custody or detention that has been imposed as a result of the commitment proceedings.
Because our ruling may preclude the civil commitment of persons who otherwise qualify as sexually violent predators, we certify the following question to the supreme court as one of great public importance:
DOES THE STATE HAVE JURISDICTION TO INITIATE CIVIL COMMITMENT PROCEEDINGS UNDER THE INVOLUNTARY CIVIL COMMITMENT OF SEXUALLY VIOLENT PREDATORS ACT AGAINST AN INMATE WHO IS ENTITLED TO IMMEDIATE RELEASE BASED ON A CORRECTED AWARD OF GAIN TIME?
Petition granted.
*957 SILBERMAN and CRENSHAW, JJ., Concur.
ALTENBERND, Judge, Concurs in part and dissents in part with opinion.
ALTENBERND, Judge, Concurring in part and dissenting in part.
I concur in the certified question. I also appreciate the court's effort in this opinion to remain obedient to the supreme court's precedent in Larimore and Atkinson. Nevertheless, I am inclined to believe that this case is distinguishable from Larimore or that the supreme court should utilize the certified question in this case to narrow the effect of these opinions. Mr. Phillips should not be allowed to deprive the Department of Children and Family Services of jurisdiction over him by his own decision to forego an appeal and to delay a postconviction motion so that, on recalculation, his sentence expired before the unpreserved error was corrected.
I am not entirely confident that the appendix in this case is an adequate record to authorize a grant of relief. Although the parties agree that the facts are not in dispute, the record does not contain Mr. Phillips' judgments and sentences. The sentencing transcript from the hearing on June 10, 2004, indicates that the maximum guidelines sentence in light of Mr. Phillips' scoresheet was 5.5 years' incarceration, but we do not have that scoresheet. I would, at a minimum, feel more confident in our analysis if those documents were in our record.
Reduced to its simplest terms, Mr. Phillips was sentenced on a violation of probation in Collier County on June 10, 2004. The court imposed the maximum sentence under the guidelines of 5.5 years' incarceration. The transcript of that hearing reflects that credit for time served was not entirely resolved at the hearing. Apparently, the written sentence awarded 177 days' jail credit. No one objected to these procedures at the hearing and, apparently, no one appealed this new sentence.
Mr. Phillips' crimes were committed in 1989. By the time he was sentenced in 2004, no one in the courtroom seems to have been conversant with the sentencing law that applied in 1989. Mr. Phillips was entitled to Tripp credit for the two years he served in Georgia, and, apparently, that credit had been awarded to him in a 1992 sentence that is not in our record. See Tripp v. State, 622 So.2d 941 (Fla.1993).
If anyone in the courtroom had been more conversant with the earlier sentencing law, Mr. Phillips would have received the Tripp credit at that time. As a result, everyone would have understood that his sentence in June 2004 would reach its end by August 2005. If Mr. Phillips had appealed his sentence in 2004, it is likely that his appellate lawyer would have corrected this error by filing a motion under Florida Rule of Criminal Procedure 3.800(b) to correct the mistake, and it would have been corrected before August 2005. Under either of these hypotheticals, Mr. Phillips would have been transferred to the Department of Children and Family Services in a timely and proper process that would not require this court to issue a writ of prohibition.[7]
But Mr. Phillips waited until April 2005 to file a motion to correct a sentencing error addressing the Tripp credit. The circuit court entered an order granting that motion on September 15, 2005.[8] The *958 order explained that Mr. Phillips needed to apply for this credit from the Department of Corrections. Mr. Phillips then further delayed this process by filing a motion for rehearing that is not in our record. The trial court denied that motion in November 2005 and Mr. Phillips was released by the Department of Corrections and transferred to the Department of Children and Family Services in early December 2005.
I do not believe that the sentence imposed without objection in June 2004 was void or somehow implicitly contained two years of undisclosed jail or prison credit. Although I have not seen this sentence, I have no reason to believe that it was not a facially legal sentence.
For these purposes, it seems to me that Mr. Phillips was lawfully held by the Department of Corrections until the additional prison or jail credit for his time in Georgia was added to his sentence. Mr. Phillips should not be allowed to deprive the Department of Children and Family Services of jurisdiction over him by his own decision to forego an appeal and to delay a postconviction motion so that, on recalculation, his sentence expired before the unpreserved error was corrected.
Our interpretation of Larimore and Atkinson may have a perverse effect on sentencing in cases where a Jimmy Ryce proceeding is a possibility. Because a motion under rule 3.800(a) can be filed at any time and because, rightly or wrongly, we essentially permit de novo review of jail and prison credit under this rule, a defendant's attorney is well advised to assure there is an unpreserved error in jail or prison credit when a client may be subject to civil detention. Once the error is rendered in the sentence, the defendant need only wait until the final portion of his sentence to file a motion under rule 3.800(a) to guarantee that the error will be corrected at a point that will divest the Department of Children and Family Services from jurisdiction. I see no reason why this outcome should be required as a matter of law.
NOTES
[1]  The Involuntary Civil Commitment of Sexually Violent Predators Act, section 394.910-931, Florida Statutes (2005), is also known as the Jimmy Ryce Act.
[2]  A petition for writ of prohibition is a proper vehicle to challenge the court's lack of subject matter jurisdiction. See Citizens Prop. Ins. Corp. v. Garfinkel, 25 So.3d 62, 63 (Fla. 5th DCA 2009); Lee v. Campion, 823 So.2d 159, 159 (Fla. 4th DCA 2002); see also Larimore v. State, 2 So.3d 101, 117 (Fla.2008) (quashing decision denying petition for writ of prohibition sought to request dismissal of civil commitment petition based on lack of jurisdiction).
[3]  Section 394.9135(1), Florida Statutes (2005), provides as follows:

If the anticipated release from total confinement of a person who has been convicted of a sexually violent offense becomes immediate for any reason, the agency with jurisdiction shall upon immediate release from total confinement transfer that person to the custody of the Department of Children and Family Services to be held in an appropriate secure facility.
[4]  Section 394.9135(2) requires the multidisciplinary team to determine whether the person qualifies as a sexually violent predator within seventy-two hours. If the multidisciplinary team determines that the person qualifies as a sexually violent predator, it must provide the state attorney with a written assessment and recommendation within the seventy-two-hour time period or within the next working day if the seventy-two-hour time period ends on a weekend or holiday.
[5]  For purposes of the motion to dismiss, the parties stipulated to the accuracy of this affidavit.
[6]  A prisoner's ability to earn gain time is based on the statutes in effect at the time of the offense. See Weaver v. Graham, 450 U.S. 24, 33, 101 S.Ct. 960, 67 L.Ed.2d 17 (1981) (holding that the ex post facto clause applied to changes in gain time statutes). Phillips committed the underlying offenses in December 1989.
[7]  Although I do not agree that prohibition should be granted in this case on the ground alleged, it is noteworthy that Mr. Phillips has a pending civil commitment proceeding five years after he was released from prison. I must question the constitutionality of a procedure that holds a person in civil detention without a final determination for years when the statutes contemplate a trial within thirty days.
[8]  Admittedly, Mr. Phillips may have hoped that the trial court would resolve his motion prior to the end of August, but the resources of our trial courts are overwhelmed by such motions and this delay is not an unusual delay. Mr. Phillips' motion did not suggest that timing was critical or that his sentence was about to expire if his claim was valid.
