making borders depending on group of partitions