added mealy fsm