modified and tested kruskal