fix minor bug in state machine.