Add check for negative cycle