added check if input automaton is final