fixed write_attribute