A combination of decisions from Oregon legislators and judges a few years ago created a dangerous hole in Oregon law. Lawmakers must work to fill that hole and protect the state’s residents in the process.

As is true in all but four states (Kansas, Idaho, Montana and Utah), a person here accused of a crime may be found guilty except for insanity. If the crime is serious enough, they’re kept under the watchful eyes of the state’s Psychiatric Security Review Board. They often are housed in the Oregon State Hospital for a time equal to the maximum sentence for their crime.

There’s a catch, however, and a man named Charles Longjaw was able to take advantage of it with dire consequences.

Longjaw was a killer and a rapist, according to an article in the Malheur Enterprise. He had been found guilty but for insanity in 1986. He was released from state custody in late 2015.

The three psychiatric review board members who heard his case in 2015 heard from a state psychologist that Longjaw continued to be a dangerous man. The psychologist said Longjaw was likely to return to abusing drugs and alcohol if released from the state’s close supervision. If that happened, she said, Longjaw would surely give in to the impulses that had led to his crimes.

Still, the review board released him. Members said that under state law, they could no longer classify him as criminally insane. Their only option was to free him.

That’s because under Oregon law, those suffering from personality disorders, voluntary substance-related intoxication or sexual conduct disorders are no longer considered insane in criminal trials. Men and women with those problems must be tried as criminals and cannot be found guilty but for insanity. That wasn’t true when Longjaw found guilty but insane in 1986.

Lawmakers need to close this particular loophole, which is available only to people found guilty but insane before the law changed. Give the psychiatric review board the tools it needs to keep people like Longjaw in custody as long as need be.

Editor’s note: This editorial has been corrected to reflect the correct sex of the state psychologist.