check_range function

Check range