make heap api more robust