Partially fixed Kruskal (the professor's solution was buggy)