change partitioning alg to consider kmax