fixing Trie so it returns the correct matches