¶ 1. M.B. appeals a Washington Superior Court order denying his petition for a writ of habeas corpus seeking release from Vermont State Hospital (VSH). M.B. claims the court erred when it held that the State substantially complied with the emergency examination statutes even though M.B. was taken into police custody before the application authorizing his detention was completed. We find that any defect in M.B.’s initial custody had no bearing on the legal basis for his restraint at the time he petitioned for a writ of habeas corpus. We affirm.
¶ 2. On May 23, 2003, at the request of his mother, M.B. met with his treating psychiatrist, Dr. Donna Kiley, at her office at Northeast Kingdom Human Services (NKHS). During the appointment, M.B. became increasingly angry and repeatedly stated his refusal to take the medications prescribed for his bipolar disorder. Dr. Kiley then determined that M.B. needed to be hospitalized and recommended that he check himself into VSH. When he vehemently refused, Dr. Kiley decided M.B. met the criteria for an emergency examination pursuant to 18 V.S.A. § 7504. Dr. Kiley then called the state police to transport M.B. to the hospital, but as soon as M.B. heard mention of the police, he fled. Less than a mile from Dr. Kile/s office, M.B. flagged down the police that were sent to apprehend him. The officer took M.B. into temporary custody and transported him back to NKHS.
¶ 3. Once back at the office, M.B. saw Dr. Kiley briefly and then was interviewed at some length by Kimberly Roberge, a qualified mental health professional, who acted as the statutorily required “interested person” and completed the application for emergency examination. See 18 V.S.A. § 7504(a). During the interview, M.B. was crying, screaming, spitting, and refusing any further treatment, all of which Roberge documented to support M.B.’s emergency examination application. Once the application and physician’s certificate were completed, M.B. was transported by police to Fletcher Allen Health Care Center. He stayed there only a short *482time before being transferred to VSH for his emergency examination.
¶ 4. At VSH, Dr. Richard Munson completed an emergency psychiatric examination of M.B. and determined that he was a “person in need of treatment” pursuant to 18 V.S.A. § 7508. The State then filed an application for involuntary treatment in the Washington Family Court on May 26,2003.
¶ 5. While the application for involuntary treatment was still pending in family court, M.B. filed this petition for a writ of habeas corpus in Washington Superior Court seeking release from VSH. The superior court held a summary hearing on M.B.’s petition on June 9, 2003. After hearing argument from the parties and testimony from M.B., the court denied the petition finding that Dr. Kiley had already made the decision to complete the application for emergency examination before M.B. was placed in police custody and therefore the State had substantially complied with the spirit and intent of the statutes governing the emergency examination process. M.B. appealed. In the meantime and just prior to the family court hearing on the involuntary treatment application, the parties agreed to a ninety-day conditional order of nonhospitalization. M.B. was released from VSH on or about June 11,2003.
¶ 6. When reviewing the trial court’s factual findings, we will view them in the light most favorable to the prevailing party below, disregarding the effect of modifying evidence, and we will not set them aside unless they are clearly erroneous. Brown v. Whitcomb, 150 Vt. 106, 109, 550 A.2d 1, 3 (1988). The court’s findings will stand if there is any reasonable and credible evidence to support them. Harlow v. Miller, 147 Vt. 480, 481-82, 520 A.2d 995, 997 (1986). Our consideration of questions of law, however, is nondeferential and plenary. State v. Pollander, 167 Vt. 301, 304, 706 A.2d 1359, 1360 (1997).
¶ 7. The issue presented is whether noncompliance with statutory emergency examination application procedures justifies granting a mental health patient’s writ for habeas corpus when his then current confinement was based on a subsequent, independent, and uncontested certification for involuntary treatment. The trial court denied the petition on grounds that there was no defect in the emergency examination procedures in the first instance and therefore never addressed the propriety of bringing a writ of habeas corpus to challenge the lawfulness of the petitioner’s present restraint. We agree that M.B.’s habeas corpus petition should be denied, but for different reasons than those cited by the trial court. See Amy’s Enters, v. Sorrell, 174 Vt. 623, 625, 817 A.2d 612, 618 (2002) (mem.) (court may affirm rulings on alternative grounds than that of trial court).
¶ 8. M.B. argues that the initiation of his custody on May 23 was unlawful because the application for emergency examination authorizing his detention had not yet been completed when he was detained. This defect, M.B. asserts, tainted all subsequent legal proceedings and justifies his release from confinement on June 9. The fundamental problem with M.B.’s argument is that habeas corpus is designed to challenge the legal basis for the petitioner’s current detention. “It is well settled that a [confined person] has no right to a writ of habeas corpus unless he is entitled to immediate release, and the writ will not issue unless he is presently restrained of his liberty without warrant of law.” In re Bryant, 129 Vt. 302, 306, 276 A.2d 628, 631 (1971) (relying on holding in Stallings v. Splain, 253 U.S. 339, 343 (1920)) (emphasis added).
¶ 9. When M.B. filed his habeas corpus petition and had the corresponding hearing in superior court, he was confined pursuant to the State’s application for *483involuntary treatment pending before the family court. See 18 V.S.A. § 7508(d)(2). Section 7508(d)(2) provides that once a person is certified as being a “person in need of treatment” pursuant to § 7508(d), and an application for involuntary treatment has been filed, “the patient shall remain hospitalized pending the court’s decision on the application.” Id. M.B.’s current confinement was therefore authorized by statute and more importantly uncontested. M.B. conceded before the trial court and again at oral argument that, when he filed his habeas petition, he was lawfully in custody at VSH based on the State’s application for involuntary treatment. He further agreed that, even if the court granted his habeas corpus petition because of defective process on May 23, it would have no bearing on the legality of his detention pursuant to the pending involuntary treatment application. M.B.’s detention at the time he sought habeas corpus relief was lawful, and he was not entitled to immediate release; therefore his petition must be denied.
¶ 10. Further supporting our holding is the fact that both parties agree that the application for emergency examination authorizing M.B.’s temporary custody on May 23 and the application for involuntary treatment authorizing his confinement on June 9 were two different and wholly independent processes. The only defect M.B. points to is his temporary custody at NKHS while Dr. Kiley and Kimberly Roberge completed the application for emergency examination. Assuming without deciding that this initial custody was unlawful, the only process directly affected by the illegality was the emergency examination application authorizing M.B.’s transport to VSH and the subsequent examination. See id. § 7504(b). Once the examination was completed, the State no longer had the authority to detain M.B. pursuant to that application. The legal basis for M.B.’s detention thereafter was the independent psychiatrist’s assessment that M.B. was a “person in need of treatment” under the separate process outlined in 18 V.S.A. § 7508(d). Section 7508(d) authorized M.B.’s detention for an additional 72 hours until either he volunteered to be treated or the State filed an application for involuntary treatment. § 7508(d). The State filed the involuntary treatment application on May 26, 2003 which formed the second separate and lawful basis for M.B.’s detention. He was legally restrained on this basis when his petition was heard in superior court on June 9, 2003.
¶ 11. By the time the superior court heard the petition, any defective process M.B. might have endured had been superseded by the implementation of two different and independent processes that justified his current detention. Each of these steps could have occurred entirely independent of the previous action. As M.B.’s counsel stated at oral argument, an application for involuntary treatment could be completed and authorized even if the patient was not confined. Given the obvious distinctions between the three different bases for M.B.’s detention, we cannot find that the May 23 confinement tainted all of M.B.’s subsequent legal proceedings or justified granting his writ of habeas corpus.
¶ 12. In this case, application of the statutory procedures provided a lawful basis for M.B.’s detention at the time he filed his writ of habeas corpus. Thus, even assuming M.B. is correct that there was a defect in the statutory emergency application procedure, M.B. was not deprived of his liberty without warrant of law.
Affirmed.