improve state management