The Georgia Supreme Court ruled in two separate cases Monday that it’s unconstitutional for the government to detain defendants declared mentally incompetent to stand trial while evaluating whether they can be restored to competency.

Both cases involved men charged with sexually assaulting children. Both defendants were represented by public defenders.