fixed boundary check in gridworld