The plaintiff, Theresa S., appeals the denial by the Superior Court {Goode, J.) of her petition for a writ of habeas corpus. We reverse and grant the writ.
The plaintiff has been adjudicated a “child in need of services” (CHINS) within the meaning of RSA 169-D:2, IV (Supp. 1983). As such, she has repeatedly appeared before the Manchester District Court for truancy and related contempt of court proceedings.
The instant dispute stems from an order of the Manchester District Court on November 20, 1984, remanding the plaintiff to the care of the Youth Development Center (YDC). The court ordered the placement pursuant to RSA 169-D:17, V(a) (Supp. 1983), which authorizes the court to “punish a child for contempt of court for refusal to participate in the specific dispositional plan as ordered by the court....”
Upon her remand to the YDC, the plaintiff was placed in Cox Cottage, which also houses juveniles charged or adjudicated delinquent. She contends that her exposure to these juveniles renders her incarceration unlawful under RSA 169-D:17, V(c) (Supp. 1983) and thereby justifies habeas corpus relief.
RSA 169-D:17, V(c) (Supp. 1983) provides:
“A child found guilty of contempt may be remanded to the youth development center provided: (1) such child shall be placed in a facility certified by the administrator of the bureau of secure care, division for children and youth services, as one in which the child shall not come in contact with minors charged or adjudicated delinquent
(Emphasis added.) The defendant, the superintendent of the YDC, argues that the language of this statute is directory, not mandatory, and that it is therefore intended only to encourage, and not to require, separation of delinquents from other charges of the YDC.
This argument is without merit. The plain meaning of RSA 169-D:17, V(c) (Supp. 1983) and the policy of the child protection *55laws, RSA chapters 169-B to 169-D (Supp. 1983), require that RSA 169-D:17, V(c) (Supp. 1983) be construed to prohibit the placement of a CHINS for contempt of court in the YDC with minors charged or adjudicated delinquent.
Where possible, a statute should be construed to be consistent with its plain meaning. See Silva v. Bolsch, 120 N.H. 600, 601, 420 A.2d 301, 302 (1980). The plain meaning of the phrase “provided ...” in RSA 169-D:17, V(c) (Supp. 1983) is that the conditions listed must be fulfilled before the court may remand a child for contempt of court to the YDC. The word “shall” is similarly unambiguous. It is mandatory, not permissive, language. See N.H.-Vt. Health Serv. v. Comm’n of Ins., 122 N.H. 268, 272, 444 A.2d 508, 510 (1982).
In construing a provision of a statute, the statute is to be construed as a whole. See State Employees’ Ass’n v. Cheney, 119 N.H. 822, 826, 409 A.2d 775, 777 (1979). RSA chapters 169-B to 169-D were enacted by the legislature as one bill. We may therefore consider provisions of all three chapters in construing RSA 169-D:17, V(c) (Supp. 1983). These provisions consistently reveal a policy of prohibiting contacts between non-delinquent children and criminal elements. See RSA 169-B:11, III (Supp. 1983) (“any minor . . . detained [at a police station, jail, or the YDC] shall not be placed in a facility in which the minor can come into contact with an adult charged, convicted or committed for a criminal offense”); RSA 169-B:15 (Supp. 1983) (“no minor shall be detained at a jail or police station or other place where he can come in contact with any adult under arrest, charged with a criminal offense or serving sentence under conviction of crime”).
While this CHINS may successfully challenge her placement with delinquents under RSA 169-D-.17, V(c) (Supp. 1983), a delinquent may not challenge his placement with CHINS under RSA 169-B: 19, 1(f) (Supp. 1983) because the word “shall” does not appear in that statute and delinquents are not harmed by being mixed with their non-criminal peers. See In re John M. and David C., 122 N.H. 1120, 1124, 454 A.2d 887, 889 (1982).
“[T]he expanding function of habeas corpus is . . . reserved for those questions which involve fundamental freedoms and occasions of pressing necessity where other remedies are inadequate or ineffective.” Springer v. Hungerford, 100 N.H. 503, 506, 130 A.2d 538, 540 (1957) (emphasis added). The plaintiff is a non-delinquent child who has been unlawfully placed in the company of individuals who would be subject to criminal prosecution but for their age. See RSA 169-B:2, II (Supp. 1983).
*56The petitioner in this case could have petitioned the committing court for modification of its commitment order in the light of the facts alleged. We are not however prepared to hold in this case that the failure to petition the committing court in the first instance deprived the superior court of its habeas corpus jurisdiction. Nonetheless, in any such future cases the superior court should ordinarily decline to exercise jurisdiction unless the petitioner has sought relief from the originally committing court.
Reversed.
All concurred.