extract function