refactored heap