         let reusing = self.contentView.subviews.first
         reusing?.removeFromSuperview()
         
-        if 0..<numberOfRows ~= selectedRow, let view = self.delegate?.viewToPresent(in: self, reusing: reusing) {
+        guard selectedIndex.count == 2 else { return }
+        guard 0..<numberOfSections ~= selectedIndex.section else { return }
+        guard 0..<numberOfRows(in: selectedIndex.section) ~= selectedIndex.row else { return }
+        
+        if let view = self.delegate?.pickerView(self, viewForPresentInRow: selectedIndex, reusing: reusing) {
             
             self.contentView.addSubview(view)
             view.translatesAutoresizingMaskIntoConstraints = false

        
        guard let delegate = self.delegate else { return }
        
        delegate.selectedRow = indexPath.row
        tableView.selectRow(at: nil, animated: false, scrollPosition: .none)
        
        for cell in tableView.visibleCells {
            guard let indexPath = tableView.indexPath(for: cell) else { continue }
            cell.accessoryType = delegate.selectedRow == indexPath.row ? .checkmark : .none
        }
        
        delegate.sendActions(for: .valueChanged)

@available(iOS 11.0, *)
public protocol SDPickerViewDataSource : AnyObject {
    
    func numberOfSections(in pickerView: SDPickerView) -> Int
    
    func pickerView(_ pickerView: SDPickerView, numberOfRowsInSection section: Int) -> Int
}

@available(iOS 11.0, *)
extension SDPickerViewDataSource {
    
    public func numberOfSections(in pickerView: SDPickerView) -> Int {
        return 1
    }
}

@available(iOS 11.0, *)
