deleted unnecessary reset of visited nodes