Function isWithinRange