fix write_ff bug