add safe argument to write_by_templ