Fixed Automata Algorithm

Too pro for gamepopper