OPINION
Appellant Brad William Reinke’s application for writ of habeas corpus raises an issue of first impression involving recent statutory amendments governing the long-term commitment of defendants who are found incompetent to stand trial. Specifically, the 2005 Legislature’s article 46B.009(b)–now 46B.0095(a)–prohibits a defendant who is found incompetent to stand trial from being committed by the State to a mental hospital or other inpatient or residential facility for a period “that exceeds the maximum term provided by law for the offense for which the defendant was to be tried.” See Act of May 23, 2005, 79th Leg., R.S., ch. 324, § 3, 2005 Tex. Gen. Laws 949 (amended 2007) (current version at Tex. Code Crim. Proc. Ann. art. 46B.0095(a) (West Supp. 2010)). Once this maximum period of commitment is reached, the State must institute civil commitment proceedings if it desires to further confine the defendant in the mental-health system. Tex. Code Crim. Proc. Ann. art. 46B.0095(b). The case before us raises the question of how to calculate the maximum term under this statute when the defendant has prior convictions that could enhance his punishment–i.e., is the “maximum term” calculated as the time prescribed as punishment for the level of the indicted offense, or is the “maximum term” lengthened by punishment enhancements that could have been applied at trial based upon prior convictions? We conclude that the statute’s plain language requires that the maximum term be based upon the offense for which the defendant was to be tried without regard to the enhanced punishment that the defendant might have received had a jury both found him guilty and found enhancement allegations to be true. As such, we reverse the trial court’s denial of Reinke’s request for habeas corpus relief and conclude that Reinke has reached the “maximum term provided by law for the offense for which he was to be tried.” See id. art. 46B.0095(a). Accordingly, Reinke may only be further confined in the State mental-health system, assuming he remains incompetent to stand trial, pursuant to civil commitment proceedings under article 46B.0095(b). See id.art. 46B.0095(b).