implementing write command