trie working, but not fast enough