add negative cycle detection