second commit w/moore and mealy funct