make range check more accurate