added while loop