initial code
added while loop