this is the Mealy Controller