added write_fmt, read_fmt functions