early version of Prims