fix state machine
merge