fix bug with indexOf(index) instead of indexOf(vertex)