updated trie to return key value pairs