                     }
                 }
             } else {
-                previousRowFrame = tableView.rectForRow(at: IndexPath(row: indexPath.row - 1, section: indexPath.section))
+                previousRowFrame = secondLastCellRect
                 // Get height of empty spaces to fill.
                 let availableHeight = tableView.frame.size.height - previousRowFrame.maxY
                 if availableHeight > lastCellIntrinsicHeight {
                     height = availableHeight
+                    dynamicLastCellHeight = height
                 }
             }
         }

        return height
    }()
    
    // MARK: - Functions
    
    open func indexPaths(toInsert cells: [UITableViewCell]) -> [IndexPath] {

        dynamicLastCellHeight = intrinsicHeightCells
            ? UITableViewAutomaticDimension
            : super.tableView(tableView, heightForRowAt: superIndexPath(for: lastCellIndexPath))
        previousRowFrame = secondLastCellRect
        // Get height of empty spaces to fill.
        let availableHeight = tableView.frame.size.height - previousRowFrame.maxY
        if availableHeight.rounded() >= lastCellIntrinsicHeight {
