Appellant, the Commonwealth, contends that the trial court improperly granted appellee’s “Motion to Quash the Transcript” following a preliminary hearing at which the district justice found that the Commonwealth had made out a prima facie case against appellee. We disagree and, accordingly, affirm.
Appellee was arrested and charged with robbery, theft by unlawful taking, receiving stolen property, criminal conspiracy, terroristic threats and prohibited offensive weapons. On June 1, 1978, the district justice held a preliminary hearing, after which he found that the Commonwealth had established a prima facie case against appellee on each of the charges. Appellee was released on $50,000.00 bail. Appellee then timely filed in the Court of Common Pleas a petition captioned a “Motion to Quash the Transcript of the District Justice,” by which he sought, inter alia, to challenge the district justice’s finding. Following argument, the Court of Common Pleas, on July 24, 1978, determined that the Commonwealth had not established a prima facie case, granted the motion and directed that the transcript be quashed. The issues in this appeal are whether appellee, on *386bail before trial, could attack the alleged error at the preliminary hearing and, if so, he could properly do so by means of the “Motion to Quash the Transcript.” We conclude that appellee could challenge the finding of a prima facie case by timely filing the motion.
The proper means for testing the validity of a district justice’s determination is for an accused in custody to file a writ of habeas corpus. Commonwealth v. Hetherington, 460 Pa. 17, 331 A.2d 205 (1975). The Commonwealth argues that, once on bail, appellee could neither avail himself of the writ nor otherwise allege error at the preliminary hearing. In Commonwealth v. Weinstein, 177 Pa.Super. 1, 109 A.2d 235 (1954), this Court held that a petitioner on bail while awaiting indictment and trial was not in custody and, therefore, could not, before trial, raise allegations that the Commonwealth had failed to make out a prima facie case at the preliminary hearing. Accord, Commonwealth v. Smith, 212 Pa.Super. 403, 244 A.2d 787 (1968); Commonwealth v. Hunsicker, 189 Pa.Super. 63, 149 A.2d 584 (1959). Commonwealth v. Gordon, 254 Pa.Super. 267, 385 A.2d 1013 (1978), recently repeated the holding of Weinstein in dictum.
The crux of the question is whether an accused on bail is “in custody” for purposes of obtaining relief through recourse to the writ of habeas corpus. A writ of habeas corpus is available only where the petitioner is in “custody.” Commonwealth ex rel. Paulinski v. Isaac, 483 Pa. 467, 397 A.2d 760 (1979); accord, McNally v. Hill, 293 U.S. 131, 55 S.Ct. 24, 79 L.Ed. 238 (1933); United States ex rel. Dessus v. Commonwealth of Pennsylvania, 452 F.2d 557 (3rd Cir. 1971), cert. denied sub nom. Dessus v. Pennsylvania, 409 U.S. 853, 93 S.Ct. 184, 34 L.Ed.2d 96 (1972). Weinstein held 25 years ago that a petitioner on bail was not “in custody” for purposes of habeas corpus. Since then, however, the United States Supreme Court and our Supreme Court have made clear that one on bail is “in custody” for purposes of habeas corpus.
*387In Hensley v. Municipal Court, 411 U.S. 345, 93 S.Ct. 1571, 36 L.Ed.2d 294 (1973), the Court held that an accused released on his own recognizance pending execution of sentence was “in custody” for purposes of federal habeas corpus because he was subject to restraints on liberty not shared by the public generally. In dictum, the Court announced that bail imposed restraints of a similar nature. Following Hensley, the Court held that a petitioner on bail is “in custody” and may obtain relief through a writ of habeas corpus otherwise available. Lefkowitz v. Newsome, 420 U.S. 283, 95 S.Ct. 886, 43 L.Ed.2d 196 (1975), overruled on other grounds, Stone v. Powell, 428 U.S. 465, 96 S.Ct. 3037, 49 L.Ed.2d 1067 (1976); accord, United States ex rel. Scranton v. State of New York, 532 F.2d 292 (2d Cir. 1976); United States ex rel. Wojtycha v. Hopkins, 517 F.2d 420 (3rd Cir. 1975); Palmore v. Superior Court of District of Columbia, 169 U.S.App.D.C. 323, 515 F.2d 1294 (D.C. Cir. 1975), vacated on other grounds, 429 U.S. 915, 97 S.Ct. 305, 50 L.Ed.2d 280 (1976); United States ex rel. Russo v. Superior Court of N.J., 483 F.2d 7 (3rd Cir. 1973), cert. denied, 414 U.S. 1023, 94 S.Ct. 447, 38 L.Ed.2d 315 (1973).1
Likewise, our Supreme Court, in Commonwealth ex rel. Paulinski v. Isaac, supra, held that a petitioner on bail after the preliminary hearing and awaiting grand jury proceedings, was “in custody” for purposes of state habeas corpus proceedings. The terms of the bail were that the petitioner could not leave the city of Pittsburgh, subject to immediate incarceration for doing so, and was obliged to appear in court upon demand of both the court and the bonding company. The Court found these conditions restraints on liberty not shared by the public generally.2 The Court *388expressly repudiated Weinstein for creating an anomalous distinction between petitioners able to afford bail, and, thus, deprived of habeas corpus relief, and petitioners too poor to post bond and, as a result, permitted to file a writ of habeas corpus. Id., 483 Pa. at 473, n. 2, 397 A.2d at 764 n. 2.
Here, appellee was released upon bail of $50,000.00. The terms of the release required appellee to appear before the court at any time so directed and to give written notice to the court, the Commonwealth and the bail agency within 48 hours of a change in address and subjected him to confession of judgment, levy, sale and execution of property to satisfy the bond, even if not in default of payment on it. These restrictions clearly restrained appellee’s liberty in a way not shared by the public generally. We therefore hold that appellee, on bail, was “in custody” for purposes of filing a writ of habeas corpus before trial to challenge the finding of a prima facie case at his preliminary hearing.3
Appellee, however, titled his petition for review of the preliminary hearing not as a writ of habeas corpus, but as a “Motion to Quash the Transcript.” Nonetheless, the *389Court of Common Pleas considered the petition exactly as though it was a writ of habeas corpus and granted the same relief available to a habeas corpus petitioner. The Court of Common Pleas correctly treated the motion to quash as a writ of habeas corpus. In Commonwealth v. Hetherington, supra, our Supreme Court held that a petition labeled a “Motion to Quash” was in fact a writ of habeas corpus attacking the magistrate’s finding that the Commonwealth at the preliminary hearing had established a prima facie case. When the substance of the “Motion to Quash” is identical to that of a writ of habeas corpus, the reviewing court undertakes an identical inquiry in disposing of the issue asserted and the relief sought is the same, there is no reason why an error in label should prevent a court from seeing that justice is done. See Commonwealth v. Wadzinski, 485 Pa. 247, 401 A.2d 1129 (1978) (where petitioner should have filed an appeal, court would treat improperly brought writ of certiorari as an appeal); Commonwealth v. Schwartz, 251 Pa.Super. 36, 379 A.2d 319 (1977) (PCHA petition properly treated as petition to withdraw guilty plea where both procedures requested same relief, lower court followed same course in reviewing one as it would the other and no purpose would have been served by dismissing petition as improperly brought); cf. Commonwealth v. Montgomery, 485 Pa. 110, 401 A.2d 318 (1979) (label petitioner placed on issue irrelevant to substance, which alone determines propriety of court’s review); Commonwealth of Pa., Auditor General v. Borough of East Washington, 474 Pa. 226, 378 A.2d 301 (1977) (form of action seeking review of agency determination irrelevant to whether court could exercise review); Pa.R.App.P. 1502 (and Comment thereto) and 1504 (same).4
Order affirmed.