add control flow logic so trie data is sent only once