fix ending state