fixed crashing bugs in bellmanFord()