added writing to file and extract among others