Walking on edges and vertices. Not working properly