fix for writing bug