 extension InsertMediaSearchResultsCollectionViewController: UISearchBarDelegate {
     
 }
+
+private extension Array {
+    subscript(safeIndex index: Int) -> Element? {
+        guard index >= 0, index < endIndex else {
+            return nil
+        }
+        return self[index]
+    }
+}

    private let collectionView: UICollectionView
    private let itemDimension: CGFloat = 100

    var results = [MWKSearchResult]() {
        didSet {
            assert(Thread.isMainThread)
            reload()

    }

    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        return searchResults.count
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
