used heapq to get smallest and largest