Alternate DFA implementation that actually works