Refactor goal state check