fixed another bug for while loop when used with function.