fix one more issue about the ending state