A trie-based approach for compacting automata