rewrote chunking using a chunkWriter