added while loop snippet