Hi, I have this DFS recursive code that works perfectly. (I need to get the number of vertex visited, so im using DFS)

Java Code:
public void DFS(int v){

visited++; //for couting the visited vertex
vertexVisited[v] = 1;
for (int w : neighbors(v))
      if (vertexVisited[w]==0) 
      DFS(w);
}

But now I need the iteractive way of this DFS function. So I tried to convert it to be iteractive way;

Java Code:
 public void DFS(int v) {

vertexVisited[v] = 1;
visited++ ;
Stack<Integer>  s = new Stack<Integer>();
for (int x : neighbors(v))
     lol.push(x);

 while(!s.isEmpty()){
        int w= lol.pop();
  	for (int u : neighbors(w))
            if(vertexVisited[u]==0)
  	    {
  	      vertvisited[u] = 1;
  	      s.push(u);
  	      visited++;
  	     }	
  		  
  	}
but is not working properly,(is not getting the number of visited vertex in right way)
can anyone tell me if this "translation" is right? or whats is wrong it that "translation"?