changed to one query for priorities