Finish balance_partitions fuctions