prim now stops if the remaining data falls below the threshold