write function update