state refactor