update prepare_files function