dfa implemented and tested