Fix to use `write_attribute`