WASHINGTON (AP) — The House passed an extensive criminal justice bill on Thursday that will reduce some of the harshest sentences for federal drug offenders and boost prison rehabilitation programs.

The bill passed 358-36 and now goes to President Donald Trump for his signature. He had urged lawmakers to support it, saying the bill would provide hope and a second chance to those who earn it.

The legislation addresses concerns that the nation’s war on drugs led to the imprisonment of too many Americans for nonviolent crimes. The nation’s federal prison population has soared by more than 700 percent since the 1980s.

The bill gives judges more discretion in sentencing some drug offenders and reduces some mandatory-minimum sentences. It also enhances efforts to better prepare inmates for life outside of prison.