Handle write command