added negative cycle detector