“Social distancing” isn’t easy in jails and prisons. Many states and localities are issuing orders to release inmates in an effort to prevent spread of the novel coronavirus. But while it makes sense to release some first-time and low-level offenders, some states and counties are going about it in a way that puts the public at risk.

Inmates in jails and state and federal prisons are routinely held in close proximity. Municipal and county jails, which hold defendants awaiting trial, have a much higher turnover, creating a ripe environment for transmission of the coronavirus. Prudence dictates taking steps to prevent this, but prudence also prioritizes public safety—and the blanket release of entire classes of suspected or convicted offenders, regardless of risk, must not happen. Individual risk assessments must be applied before releasing anyone.

In places that have failed to do this and instead rushed ahead with blanket release orders, the consequences are real. In Kentucky, Jacob Burnett was released from a Louisville jail because of coronavirus concerns. He’d served only two weeks of a two-year sentence for possession of a firearm by a felon. Four days after being released he allegedly stabbed someone to death and was rearrested and charged with murder. New York officials have thrown caution to the wind, releasing 50 inmates from the Monroe County jail. Eight of those sprung are registered sex offenders, including three considered “level 3” offenders—deemed by the courts as the most likely to re-offend.

At the other extreme, the Federal Bureau of Prisons holds thousands of nonviolent offenders in minimum-security camps. These are inmates with an extraordinarily low risk of recidivism, yet the bureau has refused so far to send prisoners to home confinement, where they can be electronically monitored. Why are high-risk local and state inmates being hurriedly released, while relatively low-risk federal prisoners are held in an environment where they are at risk of getting sick?

There’s a rational and expeditious way to reduce the spread of the coronavirus in prisons and jails. Begin with pretrial detainees, who have yet to be convicted. They must be subjected to risk assessments to identify and release those who present no significant threat to public safety. Risk assessments involve an empirical calculation that determines a person’s risk of flight or rearrest based upon his individual criminal history. They ought to be natural supplements to judicial discretion. Those discharged can be released on their own recognizance—say, in cases of minor traffic or drug offenses—or to home confinement or electronic monitoring, where appropriate.

Meanwhile, nonviolent state and federal prisoners—and the elderly, the immunocompromised and those imprisoned for technical violations—should be released and placed under supervision. These decisions must be made on an individual basis, and include a review of the inmate’s criminal history and behavior while behind bars.

In some state and federal prisons, staff and prisoners alike have tested positive for Covid-19. Yet out of fear that they’ll appear soft on crime, the agencies responsible for these facilities have failed to act. Social distancing and constant hand-washing are impossible when you’re incarcerated or work in a prison. There’s not a lot of hand sanitizer on the inside. No one deserves a death sentence for failing a drug test or missing a meeting with a probation officer.

The spread of the novel coronavirus has understandably created many issues that are competing for our attention all at once. Public health is on that list. But so is public safety. Elected officials must not foolishly privilege one over the other, which is what blanket releases of inmates do. Instead, we can sensibly protect both health and safety by basing release decision on risk to the community. The tools and the knowledge to do this already exist.