general-puspose processchunks method with many applications