fix bug when write record