added second trie distance calc