update the file saving function