code to get range partitions