added logic to test whether a partition should be compacted