new function for chunking