In Florida last month, a 16 year-old boy was attacked from behind and beaten in a juvenile detention facility by two fellow residents after he came out as gay. Reportedly, one his assailants told the victim he “didn’t want a faggot” in the unit.

In an essay for The Advocate last year, a queer youth wrote of feeling singled out, scrutinized, and harassed by homophobic staff in a juvenile detention facility. “We are already there for negative behavior,” she wrote. “We need guidance — not abandonment.”

A 2017 study by the Juvenile Law Center found that the use of solitary confinement, which can lead to depression, anxiety, paranoia, hallucinations, self-injury, and suicidality, was widespread in juvenile facilities across the country. The study also found that the practice was disproportionately applied to LGBTQ youth, youth of color, girls, and young people with disabilities.

That’s in part because some of these groups are overrepresented in the juvenile justice system. For example, in 2016, according to the U.S. Department of Justice, 856,130 youth were arrested and 45,567 were held in 1,772 residential juvenile facilities across the country. Up to 20 percent of them identify as LGBT, even though LGBT youth make up just 7 to 8 percent of the general population. Black youth are five to 10 times as likely as white youth to be incarcerated. Eighty-five percent of justice-involved youth are males.

LGBT youth are especially vulnerable to interactions with the juvenile and criminal justice systems because many of them are rejected by their families and become homeless. With limited or no options, many engage in survival crimes including prostitution, stealing, or participation in the drug trade to meet their survival needs. Many LGBT youth also experience rejection in their schools and communities. Defending themselves by fighting back sometimes involves them in the juvenile system. These youth are nearly twice as likely to experience sexual victimization in juvenile facilities, and seven times as likely to be victimized by another youth.

Nonetheless, some states, such as North Carolina, keep no data on LGBT youth in the custody of their juvenile justice systems and have done little to no research on LGBT incarceration, putting this group at greater risk for physical and sexual assault and ignoring a possible root cause of their delinquent behavior. North Carolina’s director of clinical programs for juvenile detentions and juvenile prisons contends that no transgender youth have come into a facility in the past 15 years — even though nearly 5,000 youth were committed to a state juvenile facility between 2003 and 2016. That seems highly unlikely, given what we know about the growing percentage of youth who identify as transgender (2 percent in the 2015 Massachusetts Youth Risk Behavior Survey) and about the overrepresentation of LGBT youth in the juvenile justice system generally.

The juvenile justice system can — and must — do better by our LGBT youth, while also protecting public safety. Massachusetts offers some great lessons for meaningful reform in the way LGBT youth are served within the system. Under direction from the commissioner of the state’s Department of Youth Services, the agency created a policy that would not just prohibit discrimination and harassment toward LGBT, queer, and intersex youth, but benefit all youth in the DYS system. It relied on a combination of standards mandated by law, including the Prison Rape Elimination Act, the agency’s own internal strategic planning documents, the input of staff, and outside experts. The result is a new set of practices that ensure basic best practices, such as allowing transgender and intersex youth to shower privately, dress codes that apply equally to all genders, and cultural competency training for staff and volunteers.

The U.S. juvenile justice system has as its charge the rehabilitation and therapeutic treatment of youth. For LGBT youth, recognition and respect of their identity, and an understanding of the ways it may contribute to their vulnerability to victimization, can help improve their experience of juvenile detention. That’s not just good for them — it’s good for our society and our public safety.

SEAN CAHILL, Ph.D., is director of health policy research for the Fenway Institute at Fenway Health and coauthor of the policy report “Emerging Best Practices for the Management and Treatment of Lesbian, Gay, Bisexual, Transgender, Questioning, and Intersex Youth in Juvenile Justice Settings.”