code to save the files with adjusted stuff