change code for state machine