new version of extraction function