+1, it should use a priority queue to iterate over terms