start of new implementation of prim