the visited array is now initialized in the constructor