added while loop.