inserted a while loop