fixed error in state machine