fix some writing bug