promise based state machine