Rewrite code using STL algorithm
Simple version of Trie