merge and fix for while loop change