remove function write_file for optimization