private boolean validPosition(Position position) {
        if (position.getX() < 0) {
            return false;
        }
        if (position.getX() >= xLength) {
            return false;
        }
        if (position.getY() < 0) {
            return false;
        }
        if (position.getY() >= yLength) {
            return false;
        }
        return true;
    }