bug fix in heapq