creates json file and fixed multi iteration issue