add priority queue function