Fix range checking.