added code to handle the clearing and deleting of files