Fixed error in while condition