moved the unvisited check