implement partitionBy