Generic extract function