more changes to state machine code