Added guards to keep cursor from going off the board