made the partition function easier to read with a macro