Fixed infinite loop with wasVisted() function.