handled possible wrap error in readChunks function