added while loop and data update