         return realmBrowser(showing: nil)
     }
 
-    public static func realmBrowser(showing classes:[String]?, aURL URL:URL) -> UINavigationController? {
+    public static func realmBrowser(showing classes: [String]?, aURL URL: URL) -> UINavigationController? {
         do {
             let realm = try Realm(fileURL: URL)
             return realmBrowserForRealm(realm, showing: classes)
         } catch {
-            print("realm instance at url not found.")
+            NSLog("Error occured: \(error)")
             return nil
         }
     }
 
-    public static func realmBrowser(showing classes:[String]?) -> UINavigationController? {
+    public static func realmBrowser(showing classes: [String]?) -> UINavigationController? {
         do {
             let realm = try Realm()
             return realmBrowserForRealm(realm, showing: classes)
         } catch {
-            print("realm init failed")
+            NSLog("Error occured: \(error)")
             return nil
         }
     }

        super.viewDidLoad()
        configureNavigationBar()
        configureTableView()
        fetchObjects()
        BrowserTools.checkForUpdates()
    }


        id.title = ascending == false ? RBSSortStyle.descending.rawValue: RBSSortStyle.ascending.rawValue
        ascending.toggle()
        if ascending {
//            objects = objects.sorted { $0.className > $1.className }
        } else {
//            objects = objects.sorted { $0.className < $1.className }
        }
        realmBrowserView.tableView.reloadData()
    }

    @objc public func filterBaseModels(_ id: UISegmentedControl) {
        let segmentedControl = id
        switch segmentedControl.selectedSegmentIndex {
        case 0:
//            fetchObjects()
            realmBrowserView.tableView.reloadData()
        case 1:
//            objects = objects.filter({
//                !$0.className.hasPrefix("RLM") &&
//                    !$0.className.hasPrefix("RealmSwift") })
            realmBrowserView.tableView.reloadData()
        default:
            return
        }
    }

    // MARK: - private Methods RealmObjectBrowserCell

    private func configureNavigationBar() {
        navigationItem.titleView = filterOptions
        let bbiDismiss = UIBarButtonItem(barButtonSystemItem: .stop, target: self, action: .dismissBrowser)
        let title = RBSSortStyle.ascending.rawValue
        let bbiSort = UIBarButtonItem(title: title, style: .plain, target: self, action: .sortObjects)
        self.navigationItem.rightBarButtonItems = [bbiDismiss, bbiSort]
    }

    private func configureTableView() {
        realmBrowserView.tableView.delegate = self
        realmBrowserView.tableView.dataSource = self
        realmBrowserView.tableView.tableFooterView = UIView()
        realmBrowserView.tableView.register(RealmObjectBrowserCell.self,
                                            forCellReuseIdentifier: RealmObjectBrowserCell.identifier)
        filterOptions.addTarget(self, action: .filterBaseModels, for: .valueChanged)

    }

    private func filterObjects() {
    }
}

// MARK: - Just a more beautiful way of working with selectors
private extension Selector {
    static let dismissBrowser = #selector(RBSRealmBrowser.dismissBrowser)
    static let sortObjects = #selector(RBSRealmBrowser.sortObjects(_:))
    static let filterBaseModels = #selector(RBSRealmBrowser.filterBaseModels(_:))
}

private enum RBSSortStyle: String {
    case ascending = "A-Z"
    case descending = "Z-A"
}

final class RBSRealmBrowserView: UIView {
    var tableView: UITableView
    init() {
        tableView = UITableView(frame: .zero, style: .plain)
        super.init(frame: .zero)
        tableView.backgroundColor = .white
        addSubview(tableView)
        backgroundColor = .white
    }

    required public init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override public func layoutSubviews() {
        super.layoutSubviews()
        let maxWidth: CGFloat = 414.0
        let size = CGSize(width: min(maxWidth, bounds.size.width), height: bounds.size.height)
        var xPos: Double = 0.0
        if Double(size.width) == 414.0 {
            xPos = Double((bounds.size.width - size.width))/2.0
        }
        let origin = (CGPoint(x: xPos, y: 0.0))
        tableView.frame = (CGRect(origin: origin, size: size))
    }
}

// MARK: - TableView Datasource & Delegate

extension RBSRealmBrowser: UITableViewDelegate {
    /// TableView Delegate method to handle cell selection
    ///
    /// - Parameters:
    ///   - tableView: UITableView
    ///   - indexPath: NSIndexPath
    public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        let objectSchema = engine.objectSchema(at: indexPath.row)
        let viewController = RBSRealmObjectsBrowser(className: objectSchema.className, engine: engine)
        navigationController?.pushViewController(viewController, animated: true)
    }

    /// TableView Delegate method
    ///
    /// Asks the delegate for the height to use for a row in a specified location.
    /// A nonnegative floating-point value that specifies the height (in points) that row should be.
    ///
    /// - Parameters:
    ///   - tableView: UITableView
    ///   - indexPath: NSIndexPath
    /// - Returns: height of a single tableView row
    public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return UITableView.automaticDimension
    }
}

extension RBSRealmBrowser: UITableViewDataSource {
    /// TableView DataSource method
    /// Tells the data source to return the number of rows in a given section of a table view.
    ///
    /// - Parameters:
    ///   - tableView: UITableView
    ///   - section: Int
    /// - Returns: number of cells per section
    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return engine.objectSchemas.count
    }

    /// TableView DataSource method
    /// Asks the data source for a cell to insert in a particular location of the table view.
