The state of California is drastically cutting the long-term use of solitary confinement to end a lawsuit filed by prisoners at one of the state’s most notorious prisons.

The California Department of Corrections will move nearly 2,000 inmates out of solitary confinement, in which prisoners spend all but one or two hours a day in complete isolation. Some of them have been in solitary confinement for decades, according to the Los Angeles Times. The inmate who had done the most time in solitary, 43 years, was Hugo Pinell. He was released into the general prison population last month and was killed a few days later in a riot.

The legal case behind the decision was filed by inmates serving time at Pelican Bay State Prison, which has been the focus of complaints by prisoner rights advocates for many years.

The state has used solitary confinement to keep gang members out of the general population. Prisoners could be put into solitary based on their tattoos or accusations by an informant. Under the new policy, the use of isolation will be for those who commit serious offenses such as murder, extortion or assault while in prison.

Terry Kupers, a forensic psychiatrist who had filed research findings in the case, called the decision “a game-changer. California had led the nation in keeping people in cold storage,” he told the Times.

The settlement between the state and the plaintiffs also calls for prisons to create high-security units that allow some group activity for inmates deemed too dangerous for regular prison housing.