fixed more bugs in inRange().