Scrpt for extracting threads