refactor priorityqueue