refactoring QP to support max/minPQ