Added while loop to the whole program