fix bug with improper deleting of files