added function to count partitions