bounds checking for getting ranges