work in progress on state machine