state refactoring