Improved to the max the compute_partitions function