Changed dictionary to trie