getting the state machine code in place