added while loop to iterate over a test dataset