fixed bugs with Priority Queue