
899 S.W.2d 20 (1995)
Phillip WILKINSON, Appellant,
v.
The STATE of Texas, Appellee.
No. 04-94-00573-CR.
Court of Appeals of Texas, San Antonio.
April 19, 1995.
Rehearing Denied April 19, 1995.
Discretionary Review Refused June 28, 1995.
Paul C. Looney, Houston, for appellant.
Fernando Sanchez, Asst. Dist. Atty., Laredo, for appellee.
Before RICKHOFF, STONE and DUNCAN, JJ.

ON APPELLANT'S MOTION FOR REHEARING
STONE, Justice.
The opinion issued February 8, 1995, is withdrawn and the following opinion is substituted. The motion for rehearing is denied.
Appellant, while on parole from a prior conviction, was arrested for aggravated possession of marijuana on November 29, 1993. While on bond in February, 1994, his attorney contacted the prosecutor and negotiated a deal whereby appellant agreed to cooperate in building a case against the Mexican source while the prosecutor agreed to delay seeking an indictment on the possession charge. The formal agreement was reached on April 6, 1994, and appellant was instructed to contact his parole officer to inform him of this agreement and to request permission to travel into Mexico in connection with this agreement. However, the contact with his parole officer resulted in his arrest in May of 1994 for violation of parole, i.e., his arrest for possession.
*21 On September 13, 1994, appellant filed a petition for habeas corpus seeking dismissal of prosecution with prejudice of the prior arrest, pursuant to Articles 28.061 and 32.01[1], on grounds of delay as no indictment had issued within two grand jury terms of his first arrest. The prosecutor filed the State's sworn response alleging good cause for the delay and he also obtained a grand jury indictment on the possession charge on September 20. At the habeas corpus hearing on the following day the trial court denied relief, finding the petition moot since the indictment had issued prior to the hearing.
The issue on appeal is whether the trial court erred in failing to dismiss the prosecution with prejudice when the indictment was delayed beyond the second grand jury term. Article 32.01 provides:
When a defendant has been detained in custody or held to bail for his appearance to answer any criminal accusation before the district court, the prosecution, unless otherwise ordered by the court, for good cause shown, supported by affidavit, shall be dismissed and the bail discharged, if indictment or information be not presented against such defendant at the next term of the court which is held after his commitment or admission to bail.
Article 28.061[2] renders a dismissal under 32.01 to be one with prejudice. See Nguyen v. State, 882 S.W.2d 471, 473 (Tex.App. Houston [1st Dist.] 1994) (failure to indict defendant in next term of court held after his submission to bail entitled defendant to dismissal of prosecution with prejudice).
There is no dispute that during the time between the arrest of appellant and the indictment three grand jury terms expired. Appellant filed his application for habeas corpus relief pursuant to article 32.01 prior to issuance of the indictment. The State, however, succeeded in obtaining an indictment the day before the habeas corpus hearing was held. In Payne v. State, the Court of Criminal Appeals stated,
If appellant had sought discharge from custody upon adjournment of the first succeeding term of the district court after having been remanded by the magistrate, the provision of article 576 [now 32.01] would have been controlling, but it has no application after indictment is returned although by a grand jury at a subsequent term of court.
Payne v. State, 109 Tex.Crim. 287, 4 S.W.2d 53, 54 (1928). This language has been cited by the courts for the proposition that if the indictment issues before a court rules on a 32.01 motion, the motion is moot. See, e.g., Tatum v. State, 505 S.W.2d 548, 550 (Tex. Crim.App.1974) (art. 32.01 does not apply once indictment returned); Ex parte Johnson, 142 Tex.Crim. 483, 154 S.W.2d 854, 856 (1941) (where relief is sought after second arrest, statute does not apply); Garay v. State, 683 S.W.2d 21, 22 (Tex.App.Waco 1985, pet. ref'd) (once indictment returned, art. 32.01 cannot be used to quash).
The facts in Garay are similar to appellant's situation here. In both cases grand juries failed to return an indictment until after two terms had expired. Before their respective motions to dismiss the prosecutions were heard, however, the grand juries did return indictments. The Waco Court of Appeals refused to find that the mere filing of the application for habeas corpus bars the delayed indictment. The court held instead that when an indictment is returned prior to the hearing, an article 32.01 motion to dismiss is moot. See Garay at 22.
Thus, the key for the accused but unindicted is to seek and obtain a ruling on an article 32.01 motion prior to indictment. See, e.g., Nix v. State, 882 S.W.2d 474 (Tex.App. Houston [1st Dist.] 1994) (error to deny relief to unindicted defendant where state made no *22 showing of good cause for delay); Nguyen v. State, 882 S.W.2d 471 (Tex.App.Houston [1st Dist.] 1994) (same). We disagree that appellant's situation is consistent with that of Nix and Nguyen where the defendants were not indicted until after the court erroneously denied habeas corpus relief. Appellant was indicted prior to the court's ruling.
Appellant's points of error are overruled. The order of the trial court denying the motion for dismissal of prosecution with prejudice is affirmed.
NOTES
[1]  All statutory references are to the Texas Code of Criminal Procedure.
[2]  The statute reads:

If a motion to set aside an indictment, information, or complaint for failure to provide a speedy trial is sustained, the court shall discharge the defendant. A discharge under this article or Article 32.01 of this code is a bar to any further prosecution for the offense discharged and for any other offense arising out of the same transaction, other than an offense of a higher grade that the attorney representing the state and prosecuting the offense that was discharged does not have the primary duty to prosecute.
