split save_file method into two methods