renamed partitionWhen to partition