correct a bug for negative cycle check