initializing visited to false and other stuff