The winds that determine the direction of criminal justice can be fickle — and our approach to juvenile justice is just as changeable. A few decades ago, when the panic over drugs and crime led to zero tolerance policies that put so many Americans behind bars, children didn’t fare much better. In the 1990s, a myth emerged of the “superpredator” — a new generation of uncontrollable, violent young offenders — that lead to harsher juvenile sentences and less tolerance for juvenile crimes. Increasing number of children were thrown in adult prisons, often subject to life without parole or long periods of solitary confinement.

Fortunately, those attitudes began to shift, driven in part on new research on brain development that suggested that children’’s immature brains can make them incapable of judgment and reason and should not be held to the same standards of criminal punishment as adults.

District Attorney Larry Krasner moved that idea further forward this week when he announced new policies that are intended to modify how juveniles in the justice system are dealt with. These policies will alter some of the harsher penalties and treatment that young people have been subjected to, especially those who haven’t committed serious or violent crimes, or aren’t repeat offenders.

The new policies modify some disturbing practices in our treatment of juvenile offenders: locking them up for status offenses like breaking curfew or skipping school, subjecting them to long bouts of solitary confinement, sentencing them to subpar facilities, many of which do nothing to provide education or remediation and, in at least one case, resulted in the death of a young offender. The DA also is charging fewer kids as adults, and 85 percent of those who have been charged as adults have been “decertified” to juvenile court.

This action follows closely on the heels of a federal level update of the Juvenile Justice and Delinquency Prevention Act passed last year by Congress and signed by President Trump that resets the standards for juvenile justice, including better research of minority representation in the justice system.

While there is some progress, such as declines in juvenile arrests, and court rulings, like the Supreme Court decision in 2015 that outlawed life without parole for juvenile offenders, it will take some time to entirely rewrite our brutal history of dealing with children in the justice system.

In addition to having the highest incarceration rate in the world, the U.S. also locks up more juveniles than any other country. Solidarity confinement has not been outlawed. The DA’s new measures should be especially welcome for Philadelphia, which has more than 600 young people in detention — and that’s not counting the number charged and jailed as adults.

Advocates for juvenile justice, among them, the Juvenile Law Center, are right in claiming these policy changes as a victory. But the District Attorney and his office isn’t the only one who has a role to play. Judges have enormous power over sentencing and outcomes for young offenders. Schools, communities, and the city as a whole, though, have the biggest stake in shaping the lives of troubled kids and making sure they still have a viable shot at a future.