fixed get in range function