fixed a bug in trie implementation