Implement extract function