Fixed sanity ending condition bug