somewhat fixed the extract_min bug