adding while loop and variable declarations