The hierarchical high school of John Hughes’ movies and Mean Girls is ubiquitous in pop culture, but it is not universal in real life. A new study finds that some schools—based on their size, organizational structure, and academic climate—are more likely to foster cliques than others.

Cliques form because people are often attracted to people of the same race, class, gender, and age as themselves—this is not a novel idea, and in sociology, this concept is called homophily (“love of the same”). But Daniel McFarland, an education professor at Stanford and the lead author of the study, discovered that this tendency to segregate is much more prevalent in large schools and schools that provide students with more academic freedom. A news release about the study explains: “Schools that offer students more choice—more elective courses, more ways to complete requirements, a bigger range of potential friends, more freedom to select seats in a classroom—are more likely to be rank-ordered, cliquish, and segregated.”

McFarland, whose study will be published in December in American Sociological Review, said in a phone interview that in college, when he and his peers would reflect on high school, some recalled segregated, hierarchical social scenes, while others remembered much more egalitarian environments. “Everyone had a different version of what adolescent society was like,” he said, and so he and his coauthors were interested in comparing different high schools, to see how students’ networks were shaped by the organization of their school.

The researchers used two datasets for the study: one to examine friendships on the classroom level, and the other to explore schoolwide relationships. The classroom-level dataset compared two extremely different schools. One was a traditional, tracked, Midwestern high school made up of mostly white students. The other was a magnet school in a “distressed” neighborhood of a large city that was diverse along racial and economic lines, but “homogenous in achievement.”

For the schoolwide study, an existing dataset was used that, among many other survey questions, asked thousands of adolescents at 144 different schools about their friendships. The reason for two datasets, McFarland explained, was to determine if the students formed similar networks in their classes as they did throughout the entire school. “A friend in class seems to be a fairweather friend, a weaker tie,” he said.