refactor core-logic in extract_min method