fixed errors with chunking