             }
             if let button = button, let themeModel = themeModel {
                 updateComparisonButton(button, with: themeModel, cell: cell)
-                indexPathsSelectedForComparison[button.tag] = indexPath
+                indexPathsSelectedForComparisonGroupedByButtonTags[button.tag] = indexPath
             }
             updateSelectionIndex(openSelectionIndex, for: cell, at: indexPath)
             updateSelectionThemeModel(themeModel, for: cell, at: indexPath)

            let button: UIButton?
            let themeModel: SelectionThemeModel?
            if maxNumberOfRevisionsSelected {
                assert(indexPathsSelectedForComparison.count == 1)
                if let previouslySelectedIndexPath = indexPathsSelectedForComparison.first?.value, let previouslySelectedCell = collectionView.cellForItem(at: previouslySelectedIndexPath) as?  PageHistoryCollectionViewCell {
                    if previouslySelectedIndexPath > indexPath, previouslySelectedCell.selectionIndex == 0 {
                        updateComparisonButton(secondComparisonSelectionButton, with: secondSelectionThemeModel, cell: previouslySelectedCell)
                        indexPathsSelectedForComparison[secondComparisonSelectionButton.tag] = previouslySelectedIndexPath
                        updateSelectionIndex(openSelectionIndex, for: previouslySelectedCell, at: previouslySelectedIndexPath)
                        updateSelectionThemeModel(secondSelectionThemeModel, for: previouslySelectedCell, at: previouslySelectedIndexPath)
                        openSelectionIndex = 0
                    } else if previouslySelectedIndexPath < indexPath, previouslySelectedCell.selectionIndex == 1 {
                        updateComparisonButton(firstComparisonSelectionButton, with: firstSelectionThemeModel, cell: previouslySelectedCell)
                        indexPathsSelectedForComparison[firstComparisonSelectionButton.tag] = previouslySelectedIndexPath
                        updateSelectionIndex(openSelectionIndex, for: previouslySelectedCell, at: previouslySelectedIndexPath)
                        updateSelectionThemeModel(firstSelectionThemeModel, for: previouslySelectedCell, at: previouslySelectedIndexPath)
                        openSelectionIndex = 1


    var openSelectionIndex = 0

    private var indexPathsSelectedForComparisonGroupedByButtonTags = [Int: IndexPath]() {

    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
        
