now uses priority_dict properly