
971 So.2d 212 (2008)
William Michael JOHNSON, Appellant,
v.
STATE of Florida, Appellee.
No. 4D06-2063.
District Court of Appeal of Florida, Fourth District.
January 2, 2008.
*213 Benjamin S. Waxman and Alan S. Ross of Robbins, Tunkey, Ross, Amsel, Raben & Waxman, P.A., Miami, for appellant.
Bill McCollum, Attorney General, Tallahassee, and Laura Fisher Zibura, Assistant Attorney General, West Palm Beach, for appellee.
STONE, J.
Johnson appeals his judgment and sentence, challenging the denial of his pre-sentence motion to vacate plea. We agree with Johnson that his trial counsel's deficient advice regarding possible civil commitment consequences under the Jimmy Ryce Act constituted "good cause" sufficient to permit Johnson to withdraw his guilty plea. Accordingly, we reverse and remand for further proceedings.
Johnson was charged with eight counts of lewd and lascivious battery on a person twelve years of age or older, but less than sixteen years of age. The state nolle prossed the first seven counts, and Johnson pled no contest to count eight.
The plea form, executed by Johnson and his attorney, contained an explanation of the Jimmy Ryce Act. On the form, his attorney checked a provision indicating that he had not read this document to the defendant, but had fully explained the contents to him.
At the plea hearing, the state advised that the victim and her mother were in favor of the plea agreement and asserted that there was good reason for the trial court to accept it. The state noted that the victim was a "rebellious teenager," who had "gone back and forth with her story," and that "there is no physical evidence to corroborate any of it."
During the plea colloquy, Johnson and the lawyer advised the court that the lawyer *214 had read the plea agreement to Johnson because Johnson did not have his reading glasses. The trial court accepted the plea and deferred sentencing.
Less than three months later, following a change of counsel, Johnson filed a motion to withdraw plea under rule 3.170(f), alleging that his trial counsel failed to advise him of certain Jimmy Ryce Act consequences of his plea. Essentially, he contends that he was not advised that involuntary commitment was potentially indefinite and that future criminal commitments would trigger a civil commitment under the Act, even though not related to sex offenses.
At the evidentiary hearing, Johnson testified that he did not commit the charged crimes. He claimed that he entered the plea in hope of luring the victim's mother to court so she could be arrested.[1] He believed that without the mother's influence, the victim would testify in his favor. His plan was to withdraw the plea "immediately" once the mother came to court and was arrested.
The attorney testified that he was ready to go to trial and denied advising Johnson that he would be able to withdraw his plea. The attorney advised Johnson that he could be civilly committed if he were subsequently arrested for another sex offense, but after the plea, the attorney realized that he had given Johnson incomplete advice. He never discussed with Johnson that any offense committed by someone who has a previous conviction for a sex offense is a triggering mechanism for civil commitment under the Jimmy Ryce Act. He also told Johnson that because Johnson did not have other convictions, there was an "excellent chance" he would not have any Jimmy Ryce Act concerns. The attorney denied Johnson's claim that the plea was just a ruse to get the mother arrested; he did not recall such a discussion.
Johnson moved for rehearing, or for leave to supplement the record with an affidavit, wherein he affied: "If I knew that I could be civilly committed under the Jimmy Ryce Act at any time during the rest of my life for an arrest for any offense, not only for a sex offence, I would never have plead guilty." The court declined to hear the motion because it had not been set.
Denial of a motion to withdraw plea is reviewed for abuse of discretion. See Smith v. State, 840 So.2d 404, 406 (Fla. 4th DCA 2003). Under Florida Rule of Criminal Procedure 3.170(f), the trial court may, in its discretion, and shall, on good cause, at any time before a sentence, permit a plea of guilty or no contest to be withdrawn. Thus, if there is a showing of good cause, the defendant shall be allowed to withdraw his plea as a matter of right. See id.; Wright v. State, 961 So.2d 1036, 1040 (Fla. 4th DCA 2007) ("[W]hen good cause is established, the rule entitles the defendant to withdraw the plea.").
Good cause to withdraw a plea has been found to exist "when the plea is `infected by misapprehension, undue persuasion, ignorance, or was entered by one not competent to know its consequence or that it was otherwise involuntary, or that the ends of justice would be served by withdrawal of such plea.'" Johnson v. State, 947 So.2d 1208, 1210 (Fla. 5th DCA 2007) (quoting Onnestad v. State, 404 So.2d 403, 405 (Fla. 5th DCA 1981)).
This rule should be liberally construed in favor of the defendant, as the law favors a trial on the merits. See Smith; see also Tanzi v. State, 964 So.2d 106, 113 (Fla.2007) ("[T]his presentence standard is *215 favorable to defendants, and trial courts are encouraged to liberally grant motions made before sentencing.").
We agree with the state's argument that "a failed attempt at a `vigilante' sting operation against a child victim's mother, or more likely an attempt to keep his accuser quiet by threatening to expose her mother to criminal sanctions, is clearly not a `good cause' basis for withdrawing a plea under the Rule." Nevertheless, a defendant's entry of a plea based upon his attorney's mistaken advice can be a valid basis for finding good cause. See Nicol v. State, 892 So.2d 1169, 1171 (Fla. 5th DCA 2005) (holding that trial counsel's failure to give defendant any advice regarding the possibility of suppressing his pre-trial confession based upon an argument that his arrest was illegal established good cause sufficient to permit the defendant to withdraw his plea); Graham v. State, 779 So.2d 604 (Fla. 2d DCA 2001) (holding that counsel's mistaken advice that defendant's photo would not be placed on the internet established good cause for permitting defendant to withdraw his guilty plea).
Johnson, thus, correctly argues that he should have been allowed to withdraw his plea because his attorney misadvised him about crucial aspects of the Jimmy Ryce Act.
Section 394.925, Florida Statutes, provides: "[Involuntary Civil Commitment of Sexually Violent Predators] applies to all persons currently in custody who have been convicted of a sexually violent offense, as that term is defined in s. 394.912(9),[2]as well as to all persons convicted of a sexually violent offense and sentenced to total confinement in the future." § 394.925, Fla. Stat. (2005) (emphasis supplied).[3] In regard to the Act, the use of the term "total confinement" has been interpreted to mean "in custody," despite the employment by the legislature of different terminology in each clause. See Ward v. State, 936 So.2d 1143, 1145 (Fla. 3d DCA), rev. granted, 939 So.2d 96 (Fla.2006) (citing Gordon v. Regier, 839 So.2d 715, 718-19 (Fla. 2d DCA 2003)). Thus, the Jimmy Ryce Act has been held to apply to future, non-sexual offenses. See Ward, supra; see also Tabor v. State, 864 So.2d 1171 (Fla. 4th DCA 2004), rev. denied, 908 So.2d 1058 (Fla.2005) (finding as a matter of first impression that Jimmy Ryce Act applied to defendant even though his current incarceration was not for a sexually violent crime).
In fact, just a few weeks after Johnson entered his plea, rule 3.172 went into effect, which states that:
Except when a defendant is not present for a plea, . . . the trial judge should, when determining voluntariness, place the defendant under oath and shall address the defendant personally and shall determine that he or she understands:
(9) that if the defendant pleads guilty or nolo contendere, and the offense to which the defendant is pleading is a sexually violent offense or a sexually motivated offense, or if the defendant has been previously convicted of such an offense, the plea may subject the defendant to involuntary civil commitment as a sexually violent predator upon completion *216 of his or her sentence. It shall not be necessary for the trial judge to determine whether the present or prior offenses were sexually motivated, as this admonition shall be given to all defendants in all cases.
Fla. R.Crim. P. 3.172(c)(9).
The state challenges Johnson's claim of confusion and misadvice. The record, however, reflects otherwise. Indeed, the record shows that Johnson was not advised by either the trial court or the plea form that he could be civilly committed for an indefinite period of time upon the commission of any future non-sexual offense. Nor could trial counsel have explained the Jimmy Ryce Act fully because he admitted he did not know until after Johnson's plea that sex offenders could suffer indefinite civil commitment as a result of the commission of a subsequent non-sexual offense. Thus, the attorney misadvised Johnson that Jimmy Ryce confinement could follow only conviction of sexual offenses.
The state argues that any confusion or misadvice about the Jimmy Ryce Act consequences of the plea cannot serve as a basis for relief because these are collateral consequences of the plea. See Morgan v. State, 911 So.2d 162, 164 (Fla. 3d DCA 2005) (denying post-sentence motion to withdraw plea, stating: "Defense counsel is not required to inform a client about the collateral consequences of his plea, and the application of the Jimmy Ryce Act is a collateral consequence of a plea." (internal citations omitted)). We disagree. While the "[f]ailure to inform [the defendant] of the collateral consequences may not have rendered the plea involuntary, . . . his ignorance of it does meet the `good cause' test for a pre-sentence plea withdrawal." Johnson, 947 So.2d at 1210; see also Clemmons v. State, 919 So.2d 657, 657 (Fla. 1st DCA 2006) ("[A]n offender who enters a plea in reasonable reliance on his attorney's misadvice as to a collateral consequence should be allowed to withdraw his plea.") (citing State v. Leroux, 689 So.2d 235, 238 (Fla.1996)); Graham, 779 So.2d at 605 ("[I]f collateral matters are discussed and counsel's advice is `measurably deficient,' then a plea based on that advice could be involuntary.").
Johnson had no prior criminal record and maintained his innocence throughout the proceedings. In addition, the state's case was admittedly weak. The victim even admitted that she would not testify at trial.
We reiterate that this was a pre-sentence motion to withdraw plea, and the pertinent rule must be liberally construed in favor of the defendant, as the law favors a trial on the merits. See Wright, 961 So.2d at 1040 ("This was not a request made after [the defendant] had learned of the trial court's sentence and was simply displeased with the outcome.").
We conclude that the trial court abused its discretion and reverse and remand for further proceedings.
POLEN and GROSS, JJ., concur.
NOTES
[1]  According to Johnson, the mother had three outstanding warrants in Monroe County.
[2]  Section 394.912(9)(e) defines "sexually violent offense" as including a "[l]ewd, lascivious, or indecent assault or act upon or in presence of the child in violation of s. 800.04."
[3]  As originally adopted, this provision lacked the phrase "and sentenced to total confinement." See § 916.45, Fla. Stat. (Supp.1998). In the 1999 session of the Florida Legislature, it was inserted and the provision was renumbered. Johnson entered his plea in September of 2005.
