                 if let dynamicLastCellHeight = self.dynamicLastCellHeight {
                     height = dynamicLastCellHeight
                     if shouldCallHeightForRow {
-                        let currentPreviousRowFrame = tableView.rectForRow(at: IndexPath(row: indexPath.row - 1, section: indexPath.section))
+                        let currentPreviousRowFrame = secondLastCellRect
                         // Detect changes on tableView contents after dynamicLastCellHeight is set.
                         if currentPreviousRowFrame.maxY != previousRowFrame.maxY {
                             refreshDynamicLastCellHeight()

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

                    }
                }
            } else {
                previousRowFrame = secondLastCellRect
                // Get height of empty spaces to fill.
                let availableHeight = tableView.frame.size.height - previousRowFrame.maxY
                if availableHeight > lastCellIntrinsicHeight {
                    height = availableHeight
                    dynamicLastCellHeight = height
                }
            }
        }
