added save_to_automaton function