reverting while loop