first version of trie implementation