         movieCollection.dataSource = self
         searchBarCtrl.delegate = self
         
-        loadSettings()
-        
+        setupInfiniteLoadingView()
         setupRefreshControl()
         setupSearchBar()
         configureCollectionView()
         
+        loadSettings()
+        
         loadJsonData()
-        
-        setupInfiniteLoadingView()
         
         navigationController?.navigationBar.barTintColor = UIColor(red:0.98, green:0.86, blue:0.52, alpha:1.0)
         navigationController?.navigationBar.backgroundColor = UIColor(red:0.98, green:0.86, blue:0.52, alpha:1.0)

        
        if segmentViewType.selectedSegmentIndex == 0 {
            movieTable.insertSubview(refreshControl, at: 0)
        } else {
            movieCollection.insertSubview(refreshControl, at: 0)
        }
        
        setupInfiniteLoadingView()
    }
    
    // MARK: - Navigation

    
    func setupInfiniteLoadingView() {
        // Set up Infinite Scroll loading indicator
        let frame = CGRect(x: 0, y: movieTable.contentSize.height, width: movieTable.bounds.size.width, height: InfiniteScrollActivityView.defaultHeight)
        loadingMoreViewTable = InfiniteScrollActivityView(frame: frame)
        loadingMoreViewTable!.isHidden = true
    }
}

