Fixing problem in Kruskal's code