implemented handleWriteResponse