added trie and selection logic (added missing files)