code for extraction