Opinion of the Court
SULLIVAN, Judge:Appellant was brought before a military judge at a special court-martial on the charge of wrongful use of marijuana, in violation of Article 112a, Uniform Code of Military Justice, 10 U.S.C. § 912a. Before entry of pleas, defense counsel moved to suppress the results of a urinalysis test ordered by the command. This motion was granted by the military judge, and the Government appealed his ruling to the United States Navy-Marine Corps Court of Military Review. Art. 62, UCMJ, 10 U.S.C. § 862. That Court reversed the military judge in an unpublished opinion and returned the record to the convening authority for further action.
Subsequently, appellant petitioned this Court for a review of that decision. He asks particularly:
WHETHER THE MILITARY JUDGE WAS CORRECT IN APPLYING THE EXCLUSIONARY RULE WHERE THE MILITARY JUDGE DETERMINED THAT THE RANDOM DATE SELECTION PROVISIONS OF COMNAVLOG-PACINST 5350.1 § 4a CONFERRED AN IMPORTANT SAFEGUARD TO THE PRIVACY OF APPELLANT AND THE GOVERNMENT FAILED TO COMPLY WITH THIS PROVISION.
We agree with the court below that the military judge erred as a matter of law in applying the exclusionary rule in this case. However, we do so for reasons different from the one proffered by the Court of Military Review.*
*273The facts in this case are not generally in dispute. On July 29, 1985, appellant was a member of the staff at the Naval Brig, Naval Station, Seattle, Washington. On that date, all members of the staff were required to submit to a urinalysis test pursuant to Commander, Naval Logistics Command, U.S. Pacific Fleet Instruction (COMNAVLOGPACINST) 5350.1. It states in paragraph 4:
Naval Brig/Correctional Custody Unit Testing. To ensure illicit drugs are not available within these facilities, mandatory monthly testing shall be conducted. Samples collected shall be submitted to the appropriate Naval Drug Screening Lab (NDSL). Testing shall be conducted as follows:
a. Staff. Mandatory testing (100%) of all Brig and CCU staff members shall be conducted monthly with the date randomly selected.
The evidence in support of defense counsel’s motion to suppress the results of this urinalysis showed that the selection of the date for testing had been delegated to Petty Officer Landrum. He performed law-enforcement duties and was attached to the Security Investigations Division, Naval Station, Seattle. The testing date of July 29, 1985, was chosen by Petty Officer Land-rum and ultimately approved by his superi- or for various reasons related to operational constraints. These constraints were the presence of the members to be tested, the availability of personnel to conduct the tests, and conflicts with other command operations.
With this evidence before him, the military judge found that the command had violated its own regulation by failing to “randomly select” a date for the urinalysis tests. He also suggested that there was subterfuge implied in the testing pattern because a substantial number of the tests had been scheduled for the end of the month. Finally, he concluded that the urinalysis testing had run afoul of this Court’s decision in United States v. Harris, 5 M.J. 44 (C.M.A. 1978), because selection of the date had been left to the discretion of a law-enforcement officer with no guidelines from higher authority.
The initial question we must decide is whether paragraph 4a of COMNAVLOG-PACINST 5350.1 (May 22,1984) was violated in the present case. The military judge particularly held that random meant “[l]eft to chance or haphazard.” He also held the provision for random selection was obviously intended to benefit the person tested by reducing the opportunities for “subterfuge searches.” Finally, he ruled that Petty Officer Landrum’s consideration of manpower constraints in conducting the test was impermissible under this regulatory provision.
We hold that the military judge erred as a matter of law in construing and applying this regulation. Terms in a regulation must be interpreted in light of the regulatory context in which they are found and in view of the purpose of the regulation as a whole. See United States v. Voorhees, 4 U.S.C.M.A. 509, 528, 16 C.M.R. 83, 102 (1954). Besides requiring random selection of a test date, this regulation also required 100% testing of all Brig staff members and that such testing be on a date (singular). These additional requirements dictate that consideration be given to the dates on which all members of the staff would be present. In addition, we note that the basic purpose of this regulatory procedure was “[t]o ensure illicit drugs are not available within these facilities.” Such an end would clearly be frustrated if the testing could not be practically accomplished on the day selected. Finally, the primary business of the military is to prepare for and wage war, not seize urine, and service regulations must be construed and executed in this context. See generally Goldman v. Weinberger, 475 U.S. 503, 106 S.Ct. 1310, 89 L.Ed.2d 478 (1986); United *274States ex rel. Toth v. Quarles, 350 U.S. 11, 17, 76 S.Ct. 1, 5, 100 L.Ed. 8 (1955).
These apparent contradictions suggest that the military judge’s abstract approach to the word “random” is incorrect. In this regard, we note that “randomly selected” is not particularly defined in the above regulation. However, “random sampling” is defined in paragraph 3 of this instruction by express reference to enclosure 4 of OPNAVINST. 5350.4. Paragraph 6a(2) of enclosure 4 of that OPNAYINST states that “prudent random samplings” may “[ljocalize and eliminate major areas of abuse.” It further states:
The uncertainty of who might be tested or when a test might be conducted enhances the deterrent efforts.
In this light, “randomly selected” means that the date be selected in a manner which is not known or cannot be predicted with certainty by the person tested.
Our interpretation of this regulatory provision is consistent with its stated concern for not only detecting illegal drug use but also effectively deterring it. See para. 6b(l), OPNAVINST, supra. Consideration of operational constraints is not constitutionally unreasonable and is contemplated in the above regulation. Of course, our holding today does not lessen the responsibility of a command to ensure that such inspections are not conducted as a subterfuge for searches. See Mil. R. Evid. 313(b), Manual for Courts-Martial, United States, 1984; para. 6b, OPNA-VINST, supra.
We next consider the military judge’s finding that there was a hint of subterfuge in the testing pattern because a greater number of tests were performed at the end of the month. (See appendix.) In resolving this issue, we note the provisions of Mil. R. Evid. 313(b), which includes the extraction of “body fluids, such as urine,” within the Rule’s definition of “inspection.” Like other lawful inspections, a urinalysis must be ordered for a legitimate purpose and be conducted in a lawful manner. United States v. Middleton, 10 M.J. 123 (C.M.A. 1981). The urinalysis to which appellant was subjected served two valid purposes. The first purpose was the special interest of the military in ferreting out illegal drugs and protecting the health and fitness of its members. Murray v. Haldeman, 16 M.J. 74 (C.M.A. 1983). The second purpose was the Naval Brig’s need to detect drug abuse among the members of the Brig staff who had daily contact with and were responsible for the security of the brig prisoners. The importance of maintaining security in the prisons provides sufficient justification for requiring that prisoners and prison employees alike submit to urinalysis tests. McDonell v. Hunter, 809 F.2d 1302 (8th Cir. 1987); Spence v. Farrier, 807 F. 2d 753 (8th Cir. 1986). See also Hudson v. Palmer, 468 U.S. 517, 104 S.Ct. 3194, 82 L.Ed.2d 393 (1984).
Although a compulsory urinalysis might fulfill the legitimate purposes of an inspection, it may still amount to a subterfuge search requiring probable cause if it were ordered primarily for the purposes of prosecution. Cf. United States v. Moore, 23 M.J. 295 (C.M.A. 1987); United States v. Law, 17 M.J. 229 (C.M.A. 1984); United States v. Austin, 21 M.J. 592 (A.C.M.R. 1985); United States v. Merchant, 760 F. 2d 963, 969 (9th Cir. 1985), cert. granted, — u.S. —, 106 S.Ct. 3293, 92 L.Ed.2d 708 (1986); dismissed, — U.S. —, 107 S.Ct. 1596, 95 L.Ed.2d — (1987). One of the reasons for drafting Mil. R. Evid. 313(b) ‘was to provide guidance to a commander as to what factors might convert an otherwise valid inspection to detect contraband into a subterfuge search for the fruits of a crime. See Drafters’ Analysis of Mil. R. Evid. 313(b), Appendix 21-82 through 21-83, Manual, supra. These include whether “(1) the examination was directed immediately following a report of a specific offense in the unit.. .and was not previously scheduled; (2) specific individuals are selected for examination; or (3) persons examined are subjected to substantially different intrusions during the same examination.” Mil. R. Evid. 313(b).
The manner in which the urinalysis was conducted in appellant’s unit met all *275the requirements for a lawful inspection under Mil. R. Evid. 313(b). There was no evidence to show that the tests were scheduled for the end of the month because one or more persons were suspected of using drugs during this period. All persons were required to submit to the urinalysis, and there was no showing that the tests, as administered, subjected anyone to any greater or lesser degree of intrusion.
We last consider the military judge’s holding that the results of the urinalysis should be suppressed because the selection date for the test had been left to the discretion of a law-enforcement officer in violation of this Court’s holding in United States v. Harris, supra. In that case a gateguard had been given authority to make such discretionary decisions concerning when the searches of cars were to be made, the method of selecting the vehicles to be stopped, the location of the operation, and the procedures to be followed in the event something was discovered. 5 M.J. at 65. Unlike that gateguard, Officer Land-rum did not have any discretion as to who would be chosen to take the test or how the tests were to be conducted. Moreover, any discretion he might have had with respect to the particular date was substantially limited by the above-mentioned regulatory requirements. Finally, Landrum’s status as a law-enforcement officer is less significant in this case because all persons within appellant’s immediate command were responsible for law-enforcement activities.
The recent case of Colorado v. Bertine, — U.S. —, 107 S.Ct. 738, 93 L.Ed.2d 739 (1987), supports our conclusion. There, the Supreme Court upheld the legality of an inventory search of a vehicle despite the fact that the officers in charge of completing the inventory had almost complete discretion as to the manner in which the inventory was to be conducted. The majority reasoned that there is no prohibition against the exercise of police discretion so long as that discretion is exercised according to standard criteria and on the basis of something other than suspicion of evidence of criminal activity. Applying this test to the discretion exercised by Officer Land-rum, we believe that his decision as to when the urinalysis tests were to be conducted was based on objective and practical considerations and not on any suspicion that appellant had .used marijuana. See also Illinois v. Krull, — U.S. —, 107 S.Ct. 1160, 94 L.Ed.2d 364 (1987); United States v. Leon, 468 U.S. 897, 104 S.Ct. 3405, 82 L.Ed.2d 677 (1984).
The decision of the United States Navy-Marine Corps Court of Military Review is affirmed.
Chief Judge EVERETT concurs.APPENDIX
9 December 1985
From: EMI Johnny M. Landrum, USN, 429-06-3625
Naval Station Seattle Security Investigations, Leading Petty Officer
To: LT. Michael W. S. Hayes, JAGO, USNR
Defense Counsel
Subj: U.S. NAVY BRIG SEATTLE TESTING DATES FOR THE PERIOD OCTOBER 1984 THROUGH AUGUST 1985 INCLUSIVE. THESE DATES WERE THE URINALYSIS TEST(ING) DATES.
1. The dates articulated below are the dates testing took place at the U.S. Navy Brig, Seattle, Washington. The dates are representative of the period October 1984 through August 1985. The dates were looked up in our log and file(s). They were looked up and verified by me as being true and correct. The dates in question appear below. On the dates appearing below urinalysis testing took place.
*2762. Dates:
[[Image here]]
3. The above information is true and correct; it was verified by me and by LT. Hayes.
4. Forwarded.
[[Image here]]
The Court of Military Review reversed the military judge because he erroneously applied its decision in United States v. Hillman, 18 M.J. 638 (N.M.C.M.R. 1984). We note that the judge relied on two additional grounds besides Hillman in granting the accused’s motion to suppress. We also express no opinion on that court’s statement that "the validity of the expansive language of United States v. Harris, 5 M.J. 44 (C.M.A. 1978), has been eroded by the adoption of ... Mil. R. Evid. 313.” Unpub. op. at 2. We need only point out that Harris was based *273on an interpretation of a provision of the Manual for Courts-Martial, United States, 1969 (Revised edition).