optimize heap construction