Because it never leaves the inner loop it seems: once in the final row, after turnLeft, its stuck in the inner loop (while isBlockedLeft || isBlockedRight) because it is blocked to the right, so it never leaves the loop and therefore moves forward infinitely...Yes probably but why? It is on the open switch