fix state machine mistake