a segment tool using trie