resolved infinite while loop