looping through xml then scanning functional