Fixed range checking. It was opposite before.