switched parameter positions of stack and visited. visited and unvisited should be next to each other