Implemented while loop.