refractored the chunkify code into its own module