updated with my strange trie implementation