*401OPINION
Per Curiam:Respondent Sean Fuller Nelson was arrested on December 19, 2000, for striking his wife, Sheri Durham, over the head with a liquor bottle, which caused her substantial injuries. On December 21, 2000, Nelson was arraigned on one felony count of battery with the use of a deadly weapon with substantial bodily harm. Due to preexisting health problems, Nelson was released on his own recognizance, and a preliminary hearing was set for January 3, 2001. At the preliminary hearing, the State indicated it was ready to proceed with Durham as a hostile witness. During the hearing, the State moved to amend the complaint to add two felony counts — the first for attempted murder with use of a deadly weapon and the second for battery constituting domestic violence, third offense. The defense announced it was ready to proceed on the original charge but objected to the filing of the amended complaint due to the late date. The judge allowed the State to amend the complaint as requested and granted a continuance to allow Nelson time to investigate the new charges. The State then requested that bail be set and that Nelson be remanded into custody. The State informed the court that the following day, Nelson was scheduled to appear in Justices’ Court Departments 4 and 7 on other cases. The judge postponed a decision on the State’s request until January 5, 2001, in order to consider the justices’ courts’ decisions in the pending matters when rendering its decision. As Nelson left the courtroom, he allegedly told the prosecutor that he was “not going to jail tomorrow.”
Nelson did not appear on January 4, 2001, and two no-bail bench warrants were issued. He also did not appear for his preliminary hearing on January 5, 2001, and a $150,000.00 bench warrant was issued. Nelson was subsequently arrested on the warrants at Durham’s apartment, and his preliminary hearing was reset for January 22, 2001.
On January 15, 2001, the State issued a subpoena to Durham but was unable to serve it before the preliminary hearing, despite attempts to deliver it to her apartment and place of employment. On January 19, 2001, the State’s investigator again attempted to *402contact Durham and left notice at her apartment of the January 22, 2001, court date.
On January 22, 2001, Durham did not show up at the 9 a.m. preliminary hearing. The arresting officer was present at the hearing, and the State indicated that it could possibly proceed with only his testimony. However, the State requested a fifteen-day continuance in order to procure Durham’s presence through a material witness warrant. Nelson’s attorney objected to the continuance on the basis that the motion did not satisfy Hill v. Sheriff1 or Bustos v. Sheriff.2 After conferring about Nelson’s in-custody status and about the Hill and Bustos requirements, the judge granted the continuance. Defense counsel again objected on the basis that a proper foundation for a continuance had not been established. In response, the prosecutor offered to be sworn in to make the request.
In his sworn statement requesting the continuance, the prosecutor, by reference, incorporated his own prior statements. He also stated that based upon his information and belief from dealing with Durham on the misdemeanor domestic battery cases, the witness was now avoiding service and that a material witness warrant would be the only way to procure her appearance in court. He also declared her an essential witness, though noted that he could not really determine whether she was essential until speaking to her. He again noted that since he did not want Nelson out of custody at that time, he would proceed with only the officer’s testimony if the continuance was denied. The court again granted the motion but noted that the court would not grant future continuances. Nelson’s counsel then objected on the basis that since the State had elected to go forward with the case rather than dismissing it and going to the grand jury, a continuance for the grounds specified was improper. Specifically, Nelson argued that the summons to Durham had not even been served and that the prosecutor’s statements acknowledged that the State was not surprised that the victim did not show up. Nelson argued that without surprise a Bustos motion was improper. The State argued that until the morning of the preliminary hearing, it did not realize that admission of Durham’s statements to the arresting officer — as excited utterances — might be more problematic than anticipated because she had been under the influence at the time of the statements. The preliminary hearing was reset for February 5, 2001.
On January 23, 2001, Nelson filed a petition for a writ of habeas corpus and a hearing was set for February 6, 2001, in *403Department II of the district court.3 The basis for the petition was that the State failed to use proper procedural methods to obtain the continuance because the State’s motion did not conform to Hill or Bustos. The district judge in Department II granted an ex parte request for a stay of the preliminary hearing. The State then gave Nelson notice of intent to seek an indictment and asked the district court to reconsider the stay. The district court subsequently denied the State’s motion to reconsider the stay and further ordered “any and all Grand Jury proceedings proposed by the State” stayed until further order of the court. The district court conducted hearings on the writ of habeas corpus on February 1 and 8, 2001.
The district court found that under Sheriff v. Blackmore,4 it had jurisdiction to hear the petition for the writ of habeas corpus because of the procedural violations alleged. Further, the court found that the motion for continuance was defective because there was no surprise, no written affidavit pursuant to Hill, and no verification that Durham was an essential witness. Accordingly, the district court granted the petition. Pursuant to Maes v. Sheriff,5 the court also dismissed the case with prejudice and released Nelson. The State then timely filed this appeal.
In this appeal, we are first asked to decide whether the district court had authority to grant the pretrial writ petition based on an alleged error in granting a continuance. We are also asked to decide whether the justice’s court erred in granting the continuance. We conclude that the district court had authority to consider the petition because Nelson alleged that he was being unlawfully detained in violation of the Hill and Bustos procedural requirements.
A pretrial writ of habeas corpus is not the proper avenue to challenge a discretionary ruling.6 The decision to grant a continuance is a discretionary ruling.7 However, the district court may review the legality of the detention on habeas corpus in circumstances where the continuance is alleged to have been granted in violation of the jurisdictional procedural requirements of Hill and *404Bustos.8 The district court therefore had authority to consider the pretrial petition for a writ of habeas corpus.
A continuance may be granted upon a written affidavit demonstrating good cause as outlined in Hill.9 We held in Bustos that a prosecutor also can “satisfy the purposes of the [Hill] doctrine and establish a record for review” by presenting sworn testimony of the same factual matters which are required in an affidavit.10 We have also reiterated that the aim is “to apply the [Bustos] rules ‘firmly, consistently, but realistically.’ ”11 “ ‘[G]ood cause’ is not amenable to a bright-line rule. The justices’ court must review the totality of the circumstances to determine whether ‘good cause’ has been shown.”12
Here, Nelson contends that a Bustos motion was not properly made because the prosecutor did not initially make the request under oath — though the request was subsequently repeated under oath. Nelson concluded, and the district court agreed, that this procedural deficiency in the motion negated the discretionary nature of the decision to grant a continuance and that the district court therefore properly granted the pretrial petition for a writ of habeas corpus. Nelson also alleged that the State did not prove that the witness was essential since it could have proceeded without her. He further alleged that the State could not have been surprised by the witness’s failure to appear since the subpoena had not been served upon the witness and the State had previously experienced problems with getting this witness to appear. We disagree.
We first conclude that any error in failing to have initially made the motion under oath was cured when the prosecutor subsequently repeated the substance of his motion under oath. This conclusion is consistent with our prior holding that Bustos be applied realistically.13 Further, the witness here was the victim, and the prosecutor presented the justice of the peace with valid reasons for wanting her present rather than relying on the investigating officer’s testimony of her hearsay statements. We con-*405elude that this suffices to support the State’s contention that she was essential.
We also conclude that the “surprise” requirement in Bustos was satisfied by the prosecutor’s testimony that he was surprised that the witness did not show up, and the evidence supporting his belief. The prosecutor’s belief that Durham would show up despite having problems securing her appearance in prior cases was not unreasonable given that: the witness had shown up at the initial preliminary hearing on January 3, 2001; the witness was aware that her appearance could be compelled since she had been arrested in a prior matter for not showing up as a witness; and various attempts to serve her with notice had been made, including leaving notice of the hearing at her residence the business day prior to the hearing.
Therefore, we conclude that the justice’s court properly exercised its discretion by considering the totality of the circumstances in finding that good cause existed for granting the continuance. Further we conclude that the district court, regardless of the department to which the case was assigned,14 had authority to consider the pretrial petition for a writ of habeas corpus. However, we conclude that the district court erred in granting the petition since good cause existed for the justice’s court to grant the continuance.
Accordingly, we reverse the order of the district court granting the petition for a writ of habeas corpus and remand for further proceedings consistent with this opinion.
85 Nev. 234, 452 P.2d 918 (1969), holding limited by Sheriff v. Marcus, 116 Nev. 188, 995 P.2d 1016 (2000).
87 Nev. 622, 491 P.2d 1279 (1971).
Justice’s Court Department 3 cases are scheduled to track to District Court Departments VII and XVIII rather than Department II.
99 Nev. 827, 673 P.2d 137 (1983). Throughout the record, the parties and the district court judge refer to this case as “Sheriff v. Sepulveda” or “Sepulveda.”
86 Nev. 317, 468 P.2d 332 (1970), holding limited by Sheriff v. Marcus, 116 Nev. 188, 995 P.2d 1016 (2000).
Blackmore, 99 Nev. at 830, 673 P.2d at 138.
See id.
Id. see also Sheriff v. Hatch, 100 Nev. 664, 666 n.1, 691 P.2d 449, 450 n.1 (1984).
85 Nev. at 235-36, 452 P.2d at 919.
87 Nev. at 624, 491 P.2d at 1280-81.
Sheriff v. Terpstra, 111 Nev. 860, 862, 899 P.2d 548, 550 (1995) (quoting McNair v. Sheriff, 89 Nev. 434, 438, 514 P.2d 1175, 1177 (1973)).
Id. at 863, 899 P.2d at 550.
Id. at 862, 899 P.2d at 550.
The State contends that the district court’s ruling should be vacated because the case was heard by the wrong department of the district court, in violation of EDCR 1.64. The State cites no legal authority and presents no compelling argument to support the claim that a violation of EDCR 1.64 would entitle it to the relief sought. This case was randomly assigned to Department II. Even if the incorrect department heard this case, we need not consider this argument for lack of legal authority. See NRAP 28(a)(4); see also Maresca v. State, 103 Nev. 669, 673, 748 P.2d 3, 6 (1987).