Finished new extraction function