OPINION OF THE COURT
MARIS, Circuit Judge.This civil action brought under 42 U.S.C. § 1983 by a prisoner at the Dallas, Pennsylvania State Correctional Institution sought declaratory, injunctive, compensatory and punitive relief against the Pennsylvania Commissioner of Corrections and the Superintendent and certain other officers at the Dallas institution by reason of their alleged infringement of his first amendment right to practice his religion. The plaintiff is an ordained minister of a religious faith known as the Church of Prophetic Meditation, one of the tenets of which prohibits members from cutting hair from any part of their bodies. During 1980 the plaintiff received three misconduct reports resulting in loss of privileges, segregated confinement and loss of his prison job. The misconduct alleged was his refusal to obey orders to have his hair cut in compliance with Administrative Directive 807. That directive, which regulated resident grooming, provided:1
II. MALE HAIR STYLES
Hair that does not fall below the top of the collar in length, a beard or goatee no longer than three inches, a mustache and sideburns shall be permitted provided they are neat and clean.
III. FEMALE GROOMING
A. Any feminine hair style shall be permitted.
B. Unless otherwise determined by the Superintendent of the State Correctional Institution at Muncy, hair dyeing and tinting shall be done only by the institutional beautician.
C. The use of all cosmetics shall be permitted in good taste.
The magistrate to whom the case was referred recommended that it be dismissed as frivolous. The district court adopted the magistrate’s recommendation and dismissed the complaint without service. An . appeal to this court followed. On this first appeal this court, holding that the district court had abused its discretion in treating the complaint as frivolous and that a factual record was required to strike a balance between the two competing interests in the case, reversed the judgment of dismissal and remanded the case for further proceedings. Dreibelbis v. Marks, 675 F.2d 579 (3d Cir.1982).
On remand the district court, in compiling a factual record, accepted the plaintiff’s representations that his religious beliefs were sincerely held and required that he never cut his hair or beard. The parties agreed that the plaintiff’s uncut hair and beard violated Directive 807. The defendants moved for summary judgment, sub*794mitting supporting affidavits, including an affidavit by the defendant, Commissioner of Corrections Marks, an official with more than twenty years of service in the Pennsylvania correctional system. In his affidavit Commissioner Marks set forth the potential for disruption of prison security which Directive 807 was intended to prevent. The plaintiff opposed the motion for summary judgment for the defendant, filing numerous affidavits of prisoners in the Dallas and other Pennsylvania correctional institutions to the general effect that Directive 807 was not uniformly enforced. He did not, however, offer any affidavits controverting the security dangers referred to by Commissioner Marks in his affidavit.
The district court held that the reasons set forth by the defendants for the policy involved in adopting Directive 807 were sufficient concerns which go directly to the general concept of prison regulation and security which legally justified the directive. The court concluded that the affidavits filed by the plaintiff were not relevant to his first amendment argument and that he had not made a selective enforcement claim as to which they conceivably might be relevant. The court, accordingly, entered summary judgment for the defendants. We affirm.
It is settled that, while “convicted prisoners do not forfeit all constitutional protections by reason of their conviction and confinement in prison,” Bell v. Wolfish, 441 U.S. 520, 545, 99 S.Ct. 1861, 1877, 60 L.Ed.2d 447 (1979), their right to practice their religion “may be reasonably restricted in order to facilitate the maintenance of proper discipline in the prison,” United States ex rel. Jones v. Rundle, 453 F.2d 147, 149 (3d Cir.1971). However, there has been a wide diversity in the criteria applied by various courts of appeals to determine the constitutional validity of such restrictions. Compare Gallaban v. Hollyfield, 670 F.2d 1345 (4th Cir.1982), and Teterude v. Burns, 522 F.2d 357 (8th Cir.1975), with Rogers v. Scurr, 676 F.2d 1211 (8th Cir.1982), and Brooks v. Wainwright, 428 F.2d 652 (5th Cir.1970).
In St. Claire v. Cuyler, 634 F.2d 109 (3d Cir.1980), a case which involved the religious wearing of a kufi or a turban and the attendance at a religious service, this court had occasion to review the cases. We concluded “that the state needs only to produce evidence that to permit the exercise of first amendment rights would create a potential danger to institutional security.” “This evidence,” we said, “may consist of expert testimony from the responsible officials, provided they testify to opinions that are ‘held “sincerely” and [are] arguably correct.’ ... In determining whether the state has met its burden of production, the court must be mindful of the Supreme Court’s instruction [Jones v. North Carolina Prisoners’ Labor Union, 433 U.S. 119, 133, 97 S.Ct. 2532, 2541, 53 L.Ed.2d 629 (1977)] that restrictions on first amendment rights may be deemed valid when prison officials, in the exercise of their informed discretion, conclude that there is a potential danger to security, even though the same showing might be unimpressive if submitted to justify restrictions upon members of the general public.” Finally we said, “Once the state has met its burden of going forward with the evidence, the courts must defer to the expert judgment of the prison officials unless the prisoner proves by ‘substantial evidence ... that the officials have exaggerated their response’ to security considerations ... or that their beliefs are unreasonable.” 634 F.2d at 114-115 (Supreme Court citations omitted).
With these criteria in mind, we turn to the facts of this case. The defendants supported their motion for summary judgment with the affidavit of Pennsylvania Commissioner of Corrections Marks, an officer with more than twenty years of service in the Pennsylvania corrections system. He expressed it as his opinion, based on his many years of experience in the correctional system, that Directive 807 regulating hair and beard length furthered the interests of security and order within the state correctional institutions. It is important, Marks stated, that correctional staff be able to identify inmates to avoid sitúa*795tions where altered appearances enable escapes from custody because of mistaken identity. Hair that does not fall below the collar and beards that do not exceed three inches prevent inmates from making a radical change in appearance so as to defy identification. A restriction on long hair and beards prevents concealment of contraband, such as weapons and controlled substances, on the person, thus increasing the security of an institution and limiting the potential for dangerous situations therein. In addition, the hair regulation assists in controlling homosexuality within the correctional institution. And, finally, the Marks’ affidavit stated that inmates in the prison work programs who have long hair and beards would create a dangerous situation for themselves and their coworkers. In the case of food service preparation, sanitation is improved by the restriction on long hair.
There is nothing in the record to suggest that these opinions by an expert of many years experience are not sincerely held. They are certainly arguably correct. They, therefore, satisfied the defendant’s burden of proof of validity of the directive and the burden passed to the plaintiff to prove “by substantial evidence that the officials have exaggerated their response to security considerations or that their beliefs are unreasonable.” This he has wholly failed to do, his affidavits merely tending to indicate that the directive was not uniformly enforced at Dallas and other Pennsylvania institutions. But selective enforcement or other forms - of discrimination were not averred in the complaint and were not issues in the case before the district court. Moreover, the affidavits fail to reveal the intentional or purposeful discrimination which would be necessary to support such a . claim. See Flores v. Pierce, 617 F.2d 1386, 1389 (9th Cir.), cert. denied, 449 U.S. 875, 101 S.Ct. 218, 66 L.Ed.2d 96 (1980).
Our dissenting brother suggests that the good faith of Commissioner Marks’ opinion may be questioned on two grounds. We do not think that either raises an issue of fact which precludes summary judgment. The first is that a fact finder might reasonably infer that his explanation was pretextual because of the directive’s setting differing standards for men and women prisoners. We think, however, that the distinction is justified in the Pennsylvania system of penal institutions. In Poe v. Werner, 386 F.Supp. 1014 (M.D.Pa.1974), a three-judge court in Pennsylvania held Directive 807 valid against equal protection attack on grounds of sexual discrimination. Judge Sheridan, in the opinion of the court in that case, said:
Unlike the prisons in which male inmates are incarcerated, the sole state women’s correctional institution is a minimum security facility which has no strict limitations on permissible items of personal property and no strict regimentation of conduct or personal appearance. It is an open institution where the women inmates live in cottages. The nature of the prison environment at the women’s facility differs significantly from that existing at the men’s penal institutions and hence different regulations are constitutionally permissible. See Wark v. Robbins, 1 Cir.1972, 458 F.2d 1295 (upholding differential penalties for men and women who escape from prison). Furthermore, since men and women differ physically and psychologically, the court believes that prison administrators are free to give differential treatment to male and female inmates based on perceived natural and practical differences. In the instant case the penal authorities could reasonably conclude that the greater aggressiveness and disposition toward violent action frequently displayed by male prisoners makes institutional security, maintenance of internal discipline and prevention of homosexual attacks— penal goals which the hair regulation furthers — a much greater problem in the men’s prisons than in the women’s correctional institution. Likewise the greater importance of personal appearance to *796women than men largely eliminates any hygienic problems with respect to long hair of female inmates. In short, there is a validating relationship between the varying behavioral patterns of the two sexes with respect to hair length. Thus we do not believe that the gender classification in the instant case is arbitrary; rather it rests on real and substantial differences which bear a just and reasonable relation to the purposes of the regulation. Unlike the men’s prisons, institutional security, contraband, homosexual attacks and internal discipline are not major problems at the women’s institution.
386 F.Supp. at 1020-1021. Judge Sheridan was here discussing the prison system with which we are concerned in the present ease. We are in agreement with his conclusions. We might add that the physiological differences between men and women ordinarily deny the latter the ability to grow beards, mustaches and sideburns, major subjects of the male grooming regulation. This difference is significant with respect to the problem of identification, a subject addressed in Commissioner Marks’ affidavit.
The second ground suggested for questioning the good faith of Commissioner Marks’ opinion is that it might be inferred that if security was the purpose behind Directive 807, it would be uniformly enforced and that the numerous instances of nonenforcement disclosed in the plaintiff’s affidavits suggest that the security explanation is a pretext. We cannot agree. As we have said, the affidavits fail to reveal an intentional or purposeful discrimination and, certainly, the inadvertent failure of some prison officials to enforce the directive in every instance in a far-flung prison system can hardly convict the head of the system, the Commissioner of Corrections, of bad faith in stating the basis for the directive.
The judgment of the district court will be affirmed.
. Directive 807 was superseded on December 13, 1980 by the substantially similar provisions of 37 Pa.Code §§ 93.155 and 93.156.