preventing out of bounds in checkNbr