adjusted Moore controller to work through from next state logic to state memory to output logic