Added Prim's code.