updated Write Method