added check for file deletion