After the defendant was found incompetent to stand trial on criminal charges arising out of his use of an automobile, he was committed to Taunton State Hospital (the hospital).1 The commitment order provided that the defendant “be restricted in his . . . movement to the buildings and grounds of said facility.” Upon the expiration of the initial com*87mitment order, the defendant was recommitted to the hospital pursuant to G. L. c. 123, § 16(c). However, the recommitment order contained the provision that whenever the defendant was outside the buildings and on the grounds, he was to be escorted by a hospital staff member. Protesting this new restriction, the defendant appealed to the Appellate Division of the District Court. The Appellate Division concluded that because the evidence did not demonstrate that the hospital and the Department of Mental Health (the department) were unable or unwilling to provide the level of security necessary for the defendant’s confinement, the trial judge had exceeded his authority in ordering the department to fulfill its statutory obligations in a specific manner. On the Commonwealth’s appeal, we agree with the decision of the Appellate Division.
1. Preliminary matters. Although the order in question has expired, we decline to dismiss the appeal as moot. Rather, we exercise our discretion and decide the issue raised by the Commonwealth’s appeal. See Acting Superintendent of Bournewood Hosp. v. Baker, 431 Mass. 101, 103 (2000); Cohen v. Bolduc, 435 Mass. 608, 612 (2002). Based upon our conclusion that the judge lacked the authority to enter the order in question, we think it unnecessary for us to consider the defendant’s cursory argument that any express right of appeal previously extended to the Commonwealth pursuant to G. L. c. 123, § 16(d), was “repealed” by St. 1971, c. 760, § 13.2 Accordingly, we reach the merits of the Commonwealth’s appeal.
2. The evidence. There was evidence to show that at the time of the hearing on the Commonwealth’s petition for recommitment, the defendant was in a secure facility at the hospital for *88most of each day. However, because of his treatment progress, the defendant was allowed “Level III” privileges, that is, he was given an “on-grounds pass” that allowed him to walk unescorted on the hospital’s grounds to his job in the hospital’s greenhouse or to the canteen for brief and specified periods of time. This privilege was consistent with the hospital’s policies and procedures manual, wherein it is stated that the “decision to advance patients to level III will be based upon the judgment that the patient’s clinical condition permits at least some degree of unsupervised movement around grounds” (emphasis supplied).
For the nine-month period preceding the recommitment hearing, the defendant had been participating in a behavioral management program and was being considered for placement in a planned new program to be offered by the department that was designed for people with organic mental disorders such as his and would oversee his medication. He also had been enjoying and doing well with his privileges. Although the defendant’s on-grounds pass gave him a limited window of opportunity to walk away from the hospital’s grounds, he had never attempted to do so. When his privileges were suspended just days before his recommitment hearing because of the hospital’s confusion concerning his bail status (rather than due to his behavior), the defendant managed the loss very well and without an incident comparable to his past behavior of temper tantrums.
The judge made no findings on this evidence and, instead, simply concluded that the hospital’s grounds were not secure and that “ [i]f the hospital allows a patient to move freely unescorted within the grounds [,] there is no way of enforcing the court’s ruling that he be restricted to said buildings and grounds.” Accordingly, he ordered that the defendant could not be on the grounds unless accompanied by a hospital staff member.
In vacating the judge’s order, the Appellate Division looked to the evidence and concluded that the judge had erroneously substituted his judgment for that of the hospital staff in deciding what level of security should be afforded the defendant. See Nason v. Commissioner of Mental Health, 351 Mass. 94, 96-97 (1966).
*893. Discussion. General Laws c. 123, § 16(e), as amended by St. 1973, c. 569, § 12, authorizes the imposition of certain restrictions on the movements of a person committed to a mental health facility pursuant to § 16. See Bradley v. Commissioner of Mental Health, 386 Mass. 363, 365-366 (1982). Specifically, § 16(e) provides:
“Any person committed to a facility under the provisions of this section may be restricted in his movements to the buildings and grounds of the facility at which he is committed by the court which ordered the commitment. If such restrictions are ordered, they shall not be removed except with the approval of the court. In the event the superintendent communicates his intention to remove or modify such restriction in writing to the court and within fourteen days the court does not make written objection thereto, such restrictions shall be removed by the superintendent.” (Emphases supplied.)
There is nothing in § 16(e) that expressly authorizes a court to order a facility of the department to provide staff escorts to a person restricted to its buildings and grounds. The parties do not argue otherwise. That being so, the question before us is whether the judge had the inherent or implied authority to issue the specific directive in dispute to the department, a social service agency within the executive branch of government.
As explained in Matter of McKnight, 406 Mass. 787, 792 (1990), the judiciary does have the power in certain circumstances to direct the executive branch of government to take a particular action.
“A court, of course, may not properly exercise the functions of the executive branch of State government. See Guardianship of Anthony, 402 Mass. 723, 727 (1988). On the other hand, a court has the right to order the department to do what it has a legal obligation to do. Id. Attorney Gen. v. Sheriff of Suffolk County, 394 Mass. 624, 629-630 (1985). Where the means of fulfilling that obligation is within the discretion of a public agency, the courts normally have no right to tell that agency how to fulfil its obligation. Id. at 630. See Bradley v. Commissioner of Mental Health, 386 Mass. 363, 365 (1982). Only when, at *90the time a judicial order is entered, there is but one way in which that obligation may properly be fulfilled, is a judge warranted in telling a public agency precisely how it must fulfil its legal obligation. See Guardianship of Anthony, supra at 727; Attorney Gen. v. Sheriff of Suffolk County, supra at 630.”
Ibid. (Emphasis supplied). See L.G.G. v. Department of Social Servs., 429 Mass. 1008, 1009 (1999).
There is a complete absence of evidence to support the judge’s conclusion that a staff escort was the sole method by which the hospital could carry out its statutory obligation to restrict the defendant to the buildings and grounds. See Bradley v. Commissioner of Mental Health, 386 Mass. at 366. Contrast Blaney v. Commissioner of Correction, 374 Mass. 337, 342-343 (1978) (upholding judicial instructions to department after it repeatedly failed to correct prison conditions as mandated by statute); Perez v. Boston Hous. Authy. 379 Mass. 703, 733-734 (1980) (receivership justified after housing authority persistently refused to comply with court orders based upon State sanitary code). The absence of such evidence perhaps explains why the judge made no findings of fact in support of his ultimate conclusion.
As the undisputed evidence shows, the department has a comprehensive written policy that establishes standards and procedures for the granting and withholding of patient privileges, and the hospital has a policies and procedures manual detailing the various levels of privileges extended to patients and explaining their application. These policies and procedures are entitled to deference. See Correia v. Department of Pub. Welfare, 414 Mass. 157, 169 (1993). Although the hospital did restrict the defendant to its buildings and grounds, it did so in accordance with promulgated policies and procedures. Pursuant thereto, the defendant was allowed to go unescorted on the grounds for short periods of time, that is, to and from his work program and the canteen. The time periods during which he was unescorted on the grounds were monitored, and as earlier noted, he never violated or abused his “Level III” privileges notwithstanding any limited opportunity that he might have had to do so.
*91While we are not without appreciation for the judge’s concerns, the evidence requires us to conclude, in accordance with the Appellate Division of the District Court, that the judge’s mandate that the defendant be escorted at all times when on the hospital’s grounds “constitutes an impermissible ‘poaching by the judicial branch on executive . . . territory].’ ” Guardianship of Anthony, 402 Mass. 723, 727 (1988), quoting from Attorney Gen. v. Sheriff of Suffolk County, 394 Mass. 624, 631 (1985).
4. Conclusion. It follows from what we have said that the decision and order of the Appellate Division is affirmed.
So ordered.
In 1994, the defendant attempted to drive down a pedestrian. In 1996, he was involved in an automobile accident while attempting to commit suicide. No one disputes the fact that he is mentally ill and also suffers from a severe traumatic brain injury.
Although declining to decide the question of the Commonwealth’s standing to appeal from the decision of the Appellate Division, we cannot help noting that G. L. c. 123, § 16(d), plainly authorizes a district attorney to petition a court to commit to a mental health facility a person accused of a crime but found to be incompetent to stand trial. See Commonwealth v. Killelea, 370 Mass. 638, 647 (1976). See also Commonwealth v. Nassar, 380 Mass. 908, 909 (1980); Commonwealth v. DelVerde, 398 Mass. 288, 290 (1986). Moreover, the defendant did not challenge the Commonwealth’s standing before the Appellate Division. Indeed, he served copies of his notice of appeal from the judge’s recommitment order on the “parties to the action,” that is, the defendant served his notice of appeal upon the assistant district attorney for Plymouth County and counsel for the department.