solve bug in isInRange