Updated range checking utility.