The Alaska Supreme Court ruled the state’s sex offender registry law is unconstitutional.

The court said in a 3-2 ruling on Friday that the law requiring all offenders to register violated offenders’ rights to due process.

“But its defect may be cured by providing a procedure for offenders to establish their non-dangerousness,” the ruling said.

The Alaska Sex Offender Registry Act requires those convicted of a sex offense to put their personal information, including their home address and workplace, into a state database.

“If [an offender] can show at a hearing that he does not pose a risk requiring registration, then there is no compelling reason requiring him to register, and the fact that ASORA does not provide for such a hearing means that the statute is unnecessarily broad,” the justices wrote in their opinion.

The ruling follows a 2016 lawsuit filed by an unnamed man who moved to Alaska after being convicted of aggravated sexual battery in Virginia in 2000. The man argued that Alaska did not have the legal authority to make him register because the crime happened in another state and it violated his right to privacy.

The court ruled the statute’s requirements can be constitutionally applied to sex offenders who moved to Alaska from out of state.