changed script to use chunks