Francis Kester filed a pleading styled “Motion and Notice Seeking the Board to Lift the Detainer Against Petitioner, Until Charges are Ruled on by the Superior Court”. This Court ordered that the pleading be treated as a petition for review in our original jurisdiction challenging the detainer lodged against Kester by the Pennsylvania Board of Probation and Parole (the Board). The Board filed preliminary objections in the nature of a demurrer contending that (1) detainer actions lie within this Court’s appellate jurisdiction rather than its original jurisdiction, and that (2) the petition fails to state a cause of action because the Board properly detained petitioner *34pending the disposition of new criminal charges pursuant to its authority under 37 Pa.Code § 71.3(1).
Our initial inquiry, as in all cases, is a determination of whether this Court has subject matter jurisdiction to hear the petition. This Court’s jurisdiction is governed by the Judicial Code. Our appellate jurisdiction is provided for as follows:
[T]he Commonwealth Court shall have exclusive jurisdiction of appeals from final orders of government agencies in the following cases:
(1) All appeals ... from any other Commonwealth agency having Statewide jurisdiction.
42 Pa.C.S. § 763(a)(1).
Because the Board is a Commonwealth agency having statewide jurisdiction, Kester’s petition clearly passes that prong of the test. Bronson v. Board of Probation and Parole, 491 Pa. 549, 421 A.2d 1021 (1980), certiorari denied, 450 U.S. 1050, 101 S.Ct. 1771, 68 L.Ed.2d 247 (1981). Kester’s pleading, however, challenges a detainer order. Kester was detained pursuant to 37 Pa.Code § 71.3(1) because criminal charges were pending against him. The Board must conduct a parole revocation hearing once those pending charges are resolved. See 37 Pa.Code § 71.3(2). Parole revocation orders are final orders within our appellate jurisdiction. Bronson, 491 Pa. at 555-57, 421 A.2d at 1024-25. The detainer Kester challenges is an intermediary step in the parole revocation process. Under Bronson it is not a final order. Because the detainer is not a final order, Kester’s direct challenge to that detainer is not appealable.1
The form by which a suit seeking review of an agency action is brought is not dispositive; actions should be *35treated as if filed in proper form. Commonwealth, Auditor General v. Borough of East Washington, 474 Pa. 226, 378 A.2d 301 (1977). Thus, we will examine Kester’s petition to determine whether it can be construed as challenging final agency action in any form. The prayer for relief in Kester’s petition seeks a hearing. The Board is required to conduct a preliminary hearing within thirty days of Kester’s detention under 37 Pa.Code § 71.3(9).2 This portion of Kester’s petition could be construed as a request for a remand for the Board to hold the required hearing. A petition seeking a remand for an administrative hearing properly lies within the appellate jurisdiction of this Court. O’Brien v. Commonwealth, State Employes’ Retirement System, 503 Pa. 414, 469 A.2d 1008 (1983), certiorari denied, 469 U.S. 816, 105 S.Ct. 83, 83 L.Ed.2d 30 (1984). Assuming, arguendo, that a failure to comply with Section 71.3(9) constitutes final agency action, Kester’s petition is still fatally flawed. Noticeably absent from Kester’s petition is any allegation that there has been a violation of 37 Pa.Code § 71.3(9). Without an allegation of the Board’s failure to comply with its own regulations, a petition seeking a remand for an administrative hearing cannot come within our appellate jurisdiction. •
Alternatively, Kester’s petition could invoke this Court’s original jurisdiction. The relevant portions of the section delineating that jurisdiction provide as follows:
The Commonwealth Court shall have original jurisdiction of all civil actions or proceedings:
(1) Against the Commonwealth government, including any officer thereof, acting in his official capacity, except:
*36(i) actions or proceedings in the nature of applications for a writ of habeas corpus or post-conviction relief not ancillary to proceedings within the appellate jurisdiction of the court;
42 Pa.C.S. § 761(a)(l)(i).
Read in its entirety, Kester’s pleading seeks relief from an allegedly illegal detention resulting from the Board’s detainer order. Habeas corpus is the recognized means for testing the legality of detention. Wilson v. Bureau of Corrections, 85 Pa.Commonwealth Ct. 32, 480 A.2d 392 (1984); Commonwealth v. Krall, 452 Pa. 215, 217 n. 1, 304 A.2d 488, 489 n. 1 (1973). Where the substance of a pleading is identical to a writ of habeas corpus, it should be treated as such. Commonwealth v. Orman, 268 Pa.Superior Ct. 383, 408 A.2d 518 (1979). Accord Commonwealth ex rel. Fink v. Rundle, 423 Pa. 133, 135 n. 1, 222 A.2d 717, 718 n. 1 (1966). Kester’s petition seeks habeas relief and will be so treated.3 To come within our original jurisdiction, Kester’s petition must present a habeas corpus claim ancillary to a matter within our appellate jurisdiction.
As discussed above, there is no matter yet within our appellate jurisdiction. Thus, there can be no ancillary original jurisdiction. In a case analyzing the ancillary original jurisdiction of our sister Superior Court, our Supreme Court held that ancillary jurisdiction exists only where there is a matter already on appeal before the Superior Court. Munici*37pal Publications, Inc. v. Court of Common Pleas of Philadelphia County, 507 Pa. 194, 489 A.2d 1286 (1985). In so holding, our Supreme Court expressly rejected the argument that potential appellate jurisdiction of a case conferred ancillary original jurisdiction of a related claim; ancillary original jurisdiction is limited to “instances in which an appeal has been lodged in [the appellate] court and it becomes necessary to mandate or prohibit action by a lower court in aid of the [appellate] Court’s effective exercise of its appellate jurisdiction.” Id., 507 Pa. at 200, 489 A.2d at 1288.
Further support for this interpretation is found in the Statutory Construction Act of 1972. Ancillary jurisdiction is clearly a term of art. Such phrases are to be construed according to their peculiar meaning. 1 Pa.C.S. § 1903(a). Ancillary jurisdiction is defined as the “[p]ower of court to adjudicate and determine matters incidental to the exercise of its primary jurisdiction of an action.” BLACK’S LAW DICTIONARY, 5th Ed., p. 79. Until a court is exercising its primary jurisdiction, no matter can be incidental to that exercise. Thus, no matter can be ancillary to potential appellate jurisdiction.4
The Judicial Code provides that this Court shall not dismiss an erroneously filed matter due to lack of jurisdiction; rather, the case is to be transferred to the proper court. 42 Pa.C.S. § 5103. See also Szymanski v. Allegheny County Court Criminal Division, 77 Pa.Commonwealth Ct. 316, 465 A.2d 1081 (1983). As we construe Kester’s petition as seeking a writ of habeas corpus, jurisdiction would lie in the courts of common pleas.5
*38The Judicial Code provides that venue for habeas corpus cases shall be prescribed by general rule. 42 Pa.C.S. § 6502(b). Pennsylvania Rule of Criminal Procedure 1701 governs venue when a petition seeking habeas corpus relief challenges the legality of the petitioner’s detention or the conditions of confinement in a criminal matter. Because a detainer is part of the parole revocation process, the Rules of Criminal Procedure do not apply. See Rivenbark v. Pennsylvania Board of Probation and Parole, 509 Pa. 248, 501 A.2d 1110 (1985) (rescission of parole is purely administrative function); Chapman v. Pennsylvania Board of Probation and Parole, 86 Pa.Commonwealth Ct. 49, 484 A.2d 413 (1984) (parole revocation proceedings are civil administrative matters rather than criminal prosecutions); Hossback v. Pennsylvania Board of Probation and Parole, 80 Pa.Commonwealth Ct. 344, 471 A.2d 186 (1984) (parole revocation is not part of criminal prosecution).
The detention Kester challenges is civil in nature. The Pennsylvania Rules of Civil Procedure have no specific provision governing venue for civil habeas corpus cases. The general venue provisions of those rules do not apply because the Board, an agency of the Commonwealth, is not an “individual” as that term is used in Rule 1006. The Commonwealth is mentioned as a defendant in Rule 1503. That rule, however, governs equitable actions. Habeas corpus is an action at law, not an action in equity. See Commonwealth ex rel. Levine v. Fair, 394 Pa. 262, 146 A.2d 834 (1958) (habeas corpus is a common law writ). Rule 2103 governs venue when the Commonwealth is the plaintiff. This rule does not apply here because the Board is the defendant. Thus, no rule of civil procedure specifically applies to the petition presented here.
The general import of both Pa.R.Crim.P. 1701 and Pa.R.C.P. No. 1006 is that venue lies in the judicial district where the nexus of the underlying transaction took place. Kester is being detained in the Lackawanna County Jail. The criminal charges which gave rise to the detainer were brought *39in Lackawanna County. Thus there is a substantial nexus between Lackawanna County and this petition. Accordingly, this petition is transferred to the Court of Common Pleas of Lackawanna County.6
ORDER
NOW, May 11,1992, the petition of Francis Kester, seeking habeas corpus relief in this matter, is transferred to the Court of Common Pleas of Lackawanna County.
. This Court has previously held that a detainer was final action within our appellate jurisdiction. Ryles v. Pennsylvania Board of Probation and Parole, 41 Pa.Commonwealth Ct. 337, 399 A.2d 151 (1979). Ryles was decided before our Supreme Court’s decision in Bronson which indicates that the parole revocation order is the final agency act which is subject to appellate review. Thus, Bronson implicitly overruled Ryles to that extent.
. The Board asks us to infer that Kester has either been accorded a criminal preliminary hearing or has waived that hearing. If that is true, Kester could be detained without a further hearing. 37 Pa.Code § 71.3(2); Jezick v. Pennsylvania Board of Probation and Parole, 109 Pa.Commonwealth Ct. 226, 530 A.2d 1031 (1987). The record in this case, however, is silent on those matters. Further, there is no allegation by either party that a detention hearing was conducted by an examiner as required by § 71.3(l)(iv). Thus, it is unclear whether 37 Pa.Code § 71.3(2), allowing a detention without further hearing, applies. Accordingly, we will view the record as requiring the Board to comply with the thirty day hearing requirement of § 71.3(9).
. Kester could have sought to invoke this Court’s original jurisdiction by a petition seeking mandamus relief. Mandamus is available to compel the Board to conduct a hearing or correct a legal mistake. Bronson, 491 Pa. at 554, 421 A.2d at 1023. Mandamus, however, lies "only to compel the performance of a ministerial act or mandatory duty----" St. Clair v. Pennsylvania Board of Probation and Parole, 89 Pa.Commonwealth Ct. 561, 566, 493 A.2d 146, 151 (1985). Moreover, a petition seeking mandamus must allege a legal right in the plaintiff, a corresponding duty in the defendant and want of any other adequate remedy at law. County of Allegheny v. Commonwealth, 507 Pa. 360, 490 A.2d 402 (1985). Kester’s pleading does not allege any of these three necessary elements; thus, it cannot be construed as a petition seeking mandamus. Kester does not seek mandamus and this case is distinguishable from cases involving properly pled petitions seeking such relief.
. This interpretation is also consistent with the use of the concept of ancillary jurisdiction in the Federal Court system. See Finkle v. Gulf & Western Mfg. Co., 744 F.2d 1015 (3d Cir.1984) (ancillary jurisdiction is a tool by which a federal district court acquires jurisdiction of all facets of a case properly in a federal court because a portion of the issues presented confer federal jurisdiction).
. Any judge of a court of record is empowered to issue the writ. 42 Pa.C.S. § 6502(a). All the courts of common pleas are courts of record. 42 Pa.C.S. § 321. The courts of common pleas also have unlimited original jurisdiction. 42 Pa.C.S. § 931(a). We read these three statuto*38ry sections to confer jurisdiction in this matter on the courts of common pleas.
. We note that, because habeas corpus is an extraordinary writ, a petition seeking such relief will not be granted where an alternative remedy exists. Commonwealth ex rel. Paulinski v. Isaac, 483 Pa. 467, 397 A.2d 760, certiorari denied, 442 U.S. 918, 99 S.Ct. 2841, 61 L.Ed.2d 286 (1979). Mandamus is available to correct errors of law or compel performance of a duty by the Board under Bronson. Thus, we are hard pressed to conceive of any scenario where a petition such as the one Kester presents here would be successful. Nonetheless, Kester is entitled to seek habeas corpus relief if he so chooses. 42 Pa.C.S. § 6501. Any decision on the merits of his petition must be rendered by a court with competent jurisdiction to hear the case.