added check for not empty partitions