added logic for extracting file