         else {
             cell.imageView?.image = nil
         }
+        
+        let rowsToLoadFromBotton = 5;
+        let rowsLoaded = gists.count
+        if let nextPage = nextPageURLString {
+            if (!isLoading && (indexPath.row >= (rowsLoaded - rowsToLoadFromBotton))) {
+                self.loadGists(urlToLoad: nextPage)
+            }
+        }
         return cell
     }
 


    func loadGists(urlToLoad : String?)
    {
        GitHubAPIManager.sharedInstance.getPublicGists(pageToLoad: urlToLoad) { (result, nextPage) in
            self.nextPageURLString = nextPage
            
            guard result.error == nil else
            {

    override func viewWillAppear(_ animated: Bool) {
        self.clearsSelectionOnViewWillAppear = self.splitViewController!.isCollapsed
        super.viewWillAppear(animated)
        loadGists(urlToLoad: nextPageURLString)
        //GitHubAPIManager.sharedInstance.getStarredGistWithBasicAuth()
    }

    override func didReceiveMemoryWarning() {
