I.
Lieutenant Hatheway was convicted of sodomy by a general court-martial. Article 125 of the Uniform Code of Military Justice, 10 U.S.C. § 925 (1976) makes it a crime for a serviceperson to engage “in unnatural carnal copulation with another person of the same or opposite sex.”
Prior to trial, Hatheway offered to prove that the convening authority prosecuted only cases involving homosexual sodomy, and would prosecute none involving heterosexual sodomy, even though he was aware of such cases. The Military Judge ruled that, even if Hatheway could establish those facts, his prosecution would be permissible.1
At trial, the evidence indicated Hatheway spent several hours drinking with Private Lynde, an enlisted man in his unit. They were in Lynde’s room, and Lynde’s roommates came and went during that time. Hatheway and Lynde then engaged in several acts of sodomy. Lynde’s roommate entered the room and found them undressed.
Lynde testified under a grant of immunity from sodomy or perjury prosecution. His testimony conflicted with sworn statements he had made at a preliminary investigation. He had stated that Hatheway engaged in sodomitic acts, but that he did hot. His roommate also testified.
Hatheway challenged Article 125 on various constitutional grounds as it applies to homosexual and heterosexual sodomy. He offered to prove it has a chilling effect on intraspousal, heterosexual sodomy, and introduced affidavits to the effect that sodomy prohibitions have religious origins and that homosexual acts, standing alone, are not harmful.
He also raised a defense of unconsciousness. One psychiatrist testified Hatheway suffered from “pathological intoxication” and stated his opinion that Hatheway was not conscious of the sodomitic acts. Another psychiatrist testified this was a real possibility. Hatheway objected to the use of a reasonable doubt instruction found in the Department of the Army’s Military Judges Guide. 2
Finally, Hatheway made several claims of electronic and nor.-electronic surveillance. *1379The Military Judge, pursuant to 18 U.S.C. § 3504, required the Army to affirm or deny the allegations of electronic surveillance. After three hearings, he concluded the Army’s denial was adequate.
Hatheway was convicted and sentenced to dismissal from the service. He filed extensive assignments of errors with the Army Court of Military Review which affirmed without articulating its analysis of the issues raised here.
The United States Court of Military Appeals granted Hatheway’s petition for review. It, too, affirmed without articulating its analysis of the issues, except to cite United States v. Scoby, 5 M.J. 160 (C.M.A. 1978) (upholding Article 125 as applied to acts committed in a public place).
After Hatheway’s dismissal from the service, he filed an action in district court alleging jurisdiction under 28 U.S.C. §§ 1331,1361 and 2201. He sought a declaration that his conviction was invalid, and an order that he be given an honorable discharge and all pay and benefits denied because of his conviction.
The district court granted the Secretary’s motion for summary judgment.
II.
The district court had equitable jurisdiction under 28 U.S.C. § 1331 and mandamus jurisdiction under § 1361.3 See Kauffman v. Secretary of the Air Force, 415 F.2d 991, 994-96 (D.C. Cir.), cert. denied, 396 U.S. 1013, 90 S.Ct. 572, 24 L.Ed.2d 505 (1970); Baker v. Schlesinger, 523 F.2d 1031, 1034-35 (6th Cir. 1975), cert. denied, 424 U.S. 972, 96 S.Ct. 1473, 47 L.Ed.2d 741 (1976) (mandamus); 1 Moore’s Federal Practice 10.5[4.-2] at 173-74 (2d ed. 1980). See also Schlesinger v. Councilman, 420 U.S. 738, 745, 95 S.Ct. 1300, 1306, 43 L.Ed.2d 591 (1975) (Article 76 of the Uniform Code of Military Justice, 10 U.S.C. § 876, which makes court-martial judgments binding on civilian courts, does not deprive federal courts of jurisdiction over challenges to court-martial proceedings).
The district court could not, however, directly review the determination of the military courts. “The valid, final judgments of military courts, like those of any court of competent jurisdiction not subject to direct review for errors of fact or law, have res judicata effect and preclude further litigation of the merits.” Schlesinger v. Councilman, 420 U.S. at 746, 95 S.Ct. at 1307.
The district court’s authority to order the Army to upgrade Hatheway’s discharge could be exercised only upon a determination that the court-martial judgment was void, i. e., “because of lack of jurisdiction or some other equally fundamental defect, the judgment neither justifie[d] nor bar [red] relief from its consequences.” Id. at 747, 95 S.Ct. at 1307.
The threshold question, then, is whether Hatheway has alleged a defect *1380which would justify holding his court-martial conviction void. We hold that in alleging that Article 125 is unconstitutional and that the court-martial proceedings violated his rights to due process and equal protection, he has alleged such fundamental defects.
The Secretary argues that the primary question is whether Hatheway’s constitutional arguments were given “full and fair consideration” by the military courts. The Army’s position is that if such consideration was given, there is no basis for invalidating the court-martial judgment.3 4
In Burns v. Wilson, 346 U.S. 137, 142, 73 S.Ct. 1045, 1048, 97 L.Ed. 1508 (1953), a plurality opinion stated:
In military habeas corpus cases, even more than in state habeas corpus cases, it would be in disregard of the statutory scheme if the federal civil courts failed to take account of the prior proceedings — of the fair determinations of the military tribunals after all military remedies have been exhausted .... [W]hen a military decision has dealt fully and fairly with an allegation raised in [an] application [for a writ of habeas corpus], it is not open to a federal civil court to grant the writ simply to re-evaluate the evidence.
The Burns plurality does not preclude civil court consideration of the constitutional defects alleged here. See Kauffman v. Secretary of the Air Force, 415 F.2d at 996-97. See also United States v. Augenblick, 393 U.S. 348, 351, 89 S.Ct. 528, 531, 21 L.Ed.2d 537 (1969) (suggesting proper scope of review is an open question).
In habeas corpus proceedings, a court-martial conviction may be deemed void because of constitutional defects. In Parker v. Levy, 417 U.S. 733, 94 S.Ct. 2547, 41 L.Ed.2d 439 (1974), the Court considered First Amendment arguments in an appeal from a habeas proceeding without any discussion of whether there had been “full and fair consideration” of the issues by the military courts.
We recognize, as the Supreme Court noted in Councilman, that
the grounds upon which military judgments may be impeached collaterally are not necessarily invariable. For example, grounds of impeachment cognizable in habeas proceedings may not be sufficient to warrant other forms of collateral relief. Lacking a clear statement of congressional intent one way or the other, the question whether a court-martial judgment properly may be deemed void— /. e., without res judicata effect for purposes of the matter at hand — may turn on the nature of the alleged defect, and the gravity of the harm from which relief is sought.
420 U.S. at 753, 95 S.Ct. at 1310.
Hatheway is a convicted felon. Although he has not been imprisoned, his conviction resulted in a dishonorable discharge that can cause “lasting, serious harm in civilian life.” Id. at 752, 95 S.Ct. at 1310. Given the seriousness of the harm, we think constitutional defects such as he has alleged would justify holding the conviction void.
His allegations that the Army did not comply with 18 U.S.C. § 3504(a)(1) (1976) are not sufficient, however, to merit collateral review. They were given full and fair consideration by the Military Judge.
Section 3504(a)(1) provides:
In any trial .. . upon a claim by a party aggrieved that evidence is inadmissible because it is the primary product of an unlawful act or because it was obtained by the exploitation of an unlawful act, the opponent of the claim shall affirm or deny the occurrence of the alleged unlawful act.
Hatheway’s argument is that the Army’s response to his claims of surveillance was inadequate under this statute. Although *1381the statute promotes constitutional values, see Alderman v. United States, 394 U.S. 165,180-85, 89 S.Ct. 961, 970-71, 22 L.Ed.2d 176 (1969) (illegal surveillance must be disclosed to permit adversary hearing on question of “taint”), it is analogous to a rule of discovery. Compliance is not a constitutional question, an erroneous determination of which would permit voiding the judgment of the military court.
Cf. Stone v. Powell, 428 U.S. 465, 96 S.Ct. 3037, 49 L.Ed.2d 1067 (1976) (Fourth Amendment violations not cognizable in federal habeas corpus proceeding if a full and fair hearing was provided in state courts).
III.
The Military Judge preserved Hatheway’s selective prosecution claim for appellate review by ruling that, even if the convening authority prosecuted cases involving homosexual sodomy, but refused to prosecute cases involving heterosexual sodomy, Hatheway’s prosecution would not be unconstitutional.
In order to prevail, Hatheway must establish that others are not prosecuted for the same conduct, and that the decision to prosecute was based on “impermissible” grounds. See United States v. Wilson, 639 F.2d 500 (9th Cir., 1981); United States v. Choate, 619 F.2d 21, 23 (9th Cir.), cert. denied, - U.S. -, 101 S.Ct. 354, 66 L.Ed.2d 214 (1980).
Given the ruling by the Military Judge, we must decide whether the commission of homosexual acts is an “impermissible” ground for selective prosecution under Article 125.5 We hold that it is not.
In Beller v. Middendorf, 632 F.2d 788 (9th Cir. 1980), we upheld a “military regulation which prohibits personnel from engaging in homosexual conduct while they are in the service.” Id. at 810. The litigants in Beller were given honorable discharges. The issue was whether the regulation violated their rights to personal autonomy protected by the due process clause of the Fifth Amendment. Id. at 807.
Our review of the regulation involved more than the cursory glance characteristic of the rational basis test. See id. at 809 (case lies between the two extremes of substantive due process review). Instead, we undertook a careful balancing of the nature of the individual interest, the importance of the governmental interest, the degree to which the individual interest was infringed, and the availability of less restrictive means to safeguard the governmental interest. Id. at 807-12.
It was unnecessary, given the flexibility of substantive due process analysis, to determine the precise nature of the individual interest in engaging in private homosexual conduct. Conceding that the interest might be constitutionally protected, our analysis focused on the importance of the governmental interest.
The unique demands of the military were “crucial.” Id. at 810. We considered “the *1382importance of the military’s role, the special need for discipline and order in the service, [and] the potential for difficulties arising out of possible close confinement . .. [on] bases for long periods of time.” Id. at 812. We found that, among other factors, “doubts concerning a homosexual officer’s ability to command the respect and trust of the personnel he or she commands” supported the Navy’s regulation. Id. at 811.
We concluded:
[T]he importance of the government interests furthered, and to some extent the relative impracticality at this time of achieving the Government’s goals by regulations which turn more precisely on the facts of an individual case, outweigh whatever heightened solicitude is appropriate for consensual private homosexual conduct.
Id. at 810.
We understand Hatheway’s claim (that the commission of a homosexual act is an impermissible basis for prosecution) to be an equal protection argument. We must apply the “rather formal three-tier analysis of the Court’s recent equal protection decisions,” id. at 807, instead of the more flexible substantive due process analysis that was applicable in Beller. Classifications which are based solely on sexual preference implicate the “right to be free, except in very limited circumstances, from unwarranted government intrusions into one’s privacy.” Stanley v. Georgia, 394 U.S. 557, 564, 89 S.Ct. 1243, 1247, 22 L.Ed.2d 542 (1969).6 Given the similarity of the interests at stake here and in Beller, we apply an intermediate level of review. The classification can be sustained only if it bears a substantial relationship to an important governmental interest. See, e. g., Orr v. Orr, 440 U.S. 268, 279, 99 S.Ct. 1102, 1111, 59 L.Ed.2d 306 (1979) (gender-based discrimination).
The government has a compelling interest in maintaining a strong military force. Underlying our holding in Beller was the judgment that those who engage in homosexual acts severely compromise the government’s ability to maintain such a force. That judgment was the basis for our holding that the Navy’s policy of discharging all such persons was constitutionally permissible.
The convening authority may select those cases for referral to a court-martial which involve violations of the UCMJ which are most likely to undermine discipline and order in the military. In light of Beller, we hold that selection of cases involving homosexual acts for Article 125 prosecutions bears a substantial relationship to an important governmental interest.
IV.
We next consider Hatheway’s constitutional challenges to Article 125 itself.
A.
Hatheway claims Article 125 is unconstitutional as applied to private, hetero*1383sexual acts. The Secretary argues he lacks standing to make this claim. We agree.
The general rule is that “a person to whom a statute may constitutionally be applied will not be heard to challenge that statute on the ground that it may conceivably be applied unconstitutionally to others . . .. ” Parker v. Levy, 417 U.S. at 759, 94 S.Ct. at 2563, quoting from, Broaderick v. Oklahoma, 413 U.S. 601, 610, 93 S.Ct. 2908, 2914, 37 L.Ed.2d 830 (1973). Standing will be found only where there are “weighty countervailing policies.” Id.
Parker involved a challenge to two sections of the UCMJ on ‘void for vagueness’ grounds. The Court emphasized that the First Amendment is applied uniquely in a military setting. The need for discipline and order justify limitations on individual speech and conduct that would violate the First Amendment in a civilian setting.
It held that similar concerns justify a narrow rule of standing:
[F]or the reasons dictating a different application of First Amendment principles in the military context described above, we think that the ‘weighty countervailing policies’ . . . which permit the extension of standing in First Amendment cases involving civilian society, must be accorded a good deal less weight in the military context.
Id. 417 U.S. at 760, 94 S.Ct. at 2560 (citation omitted).
Hatheway relies on Carey v. Population Services International, 431 U.S. 678, 97 S.Ct. 2010, 52 L.Ed.2d 675 (1977), for the proposition that a ‘chilling effect’ on the exercise of personal autonomy rights gives him standing to challenge Article 125 as it applies to private, heterosexual acts.
In Carey, the plaintiffs were held to be in the position of vendors who “have been uniformly permitted to resist efforts at restricting their operations by acting as advocates for the rights of third parties who seek access to their market or function.” Id. at 684, 97 S.Ct. at 2015. Carey does not support the proposition that an alleged abridgement of personal autonomy rights is a sufficient basis for relaxing the usual rules of standing.
Even if Article 125 has an effect on personal autonomy rights, that effect is not sufficiently weighty in a military setting to let Hatheway assert the rights of others as a basis for voiding his conviction. Moreover, as in Parker, this statute might be applied validly in many settings (e. g., to acts committed in public). Hatheway has not overcome the Court’s “reluctance to strike down a statute on its face where there [are] a substantial number of situations to which it might be validly applied.” 417 U.S. at 760, 94 S.Ct. at 2563.
B.
Hatheway argues Article 125 violates the First Amendment’s prohibition of laws respecting an establishment of religion. He has referred to the religious origins of laws against sodomy, a fact the Army does not dispute. Whether Article 125 violates the establishment clause' thus depends on whether it “still retains its religious character.” McGowan v. Maryland, 366 U.S. 420, 431, 81 S.Ct. 1101, 1108, 6 L.Ed.2d 393 (1961).
McGowan upheld Sunday closing laws against an establishment clause challenge. The Court noted that such laws had undergone extensive changes from their earliest forms and were often advocated by trade associations and labor groups. Id. at 433-45, 81 S.Ct. at 1109-15. It held the laws valid because their present purpose and effect, to provide a uniform day of rest, reflected legitimate secular goals.
Two courts have relied on McGowan to reject establishment clause challenges to sodomy laws. Stewart v. United States, 364 A.2d 1205, 1208-09 (D.C.1976); People v. Baldwin, 37 Cal.App.3d 385, 388-89, 112 Cal.Rptr. 290, 291-92 (1974).
The Army has not demonstrated that sodomy laws have undergone substan*1384tial revisions from their earliest forms, nor that they have been advocated by secular groups. However, the secular policies asserted by the Army, such as preventing disruptive conduct, were accepted in Beller as legitimate justifications for the Navy’s prohibition of homosexual conduct. 632 F.2d at 811. We have found that they support the convening authority’s classification of homosexual and heterosexual conduct. We therefore hold that in a military setting the proscriptions of Article 125 have a legitimate secular purpose and effect.
C.
Hatheway contends Article 125 is unconstitutional because it violates his right to personal autonomy. Although we agree that Article 125 restricts the exercise of such rights, Beller is again dispositive. As noted above, we held that in the military “the importance of the government interests furthered ... outweigh[s] whatever heightened solicitude is appropriate for consensual private homosexual conduct.” 632 F.2d at 810.
Beller did note that “[t]he instant cases . . . are not ones in which the state seeks to use its criminal processes to coerce persons to comply with a moral precept even if they are consenting adults acting in private without injury to each other.” Id. We can scarcely characterize Hatheway’s conduct as having been “in private,” because Lynde’s roommates came and went while Hatheway and Lynde were in the room. In this setting, Hatheway’s right to personal autonomy is of less weight, cf. Stanley v. Georgia, 394 U.S. 557, 564, 89 S.Ct. 1243, 1247, 22 L.Ed.2d 542 (1969) (right to receive information takes on added weight in the privacy of one’s home), and is overcome by the governmental interest in deterring homosexual conduct by members of the armed forces.
V.
The final issue is whether the Military Judge’s instruction on reasonable doubt, note 1 supra, violated Hatheway’s right to due process. Proof beyond a reasonable doubt was defined in terms of proof upon which the jury would be “willing to act,” and reasonable doubt was twice equated with “substantial doubt.” Hatheway argues the error was significant because there was a close issue regarding his defense of unconsciousness.
Those aspects of the instruction have been criticized, but never held to be reversible error. Holland v. United States, 348 U.S. 121, 140, 75 S.Ct. 127, 137, 99 L.Ed. 150 (1954) (“willing to act”); Taylor v. Kentucky, 436 U.S. 478, 488, 98 S.Ct. 1930, 1936, 56 L.Ed.2d 468 (1978) (“substantial doubt”) (dictum).
The test is whether the instruction, “taken as a whole, fairly and accurately conveys the meaning of reasonable doubt.” United States v. Robinson, 546 F.2d 309, 314 (9th Cir. 1976), cert. denied, 430 U.S. 918, 97 S.Ct. 1333, 51 L.Ed.2d 596 (1977). Even if there were a close question on Hatheway’s unconsciousness defense, or one concerning Lynde’s veracity, there was no constitutional error in the instruction. Proof beyond a reasonable doubt was defined as “proof to a moral certainty.” The other aspects of the instruction, while perhaps not ideal, did not obscure or distort the meaning of reasonable doubt.
AFFIRMED.