parsing json data and going through the loop