wip refactor state