Attempted to make an efficient pop() for heap, but failed