refactor state machine
new design in progress