Fix Bellman-Ford algorithm