tuning partitioning code