massive performance improvement by changing the way prim determines next field
made internal methods in prim private