Now checks goal state properly.