priority queue implemented; queue code minimized