finished implementing partitioning algorithm