refactored heaps