Fixed check_goal method