         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
     }
 

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

    override func didReceiveMemoryWarning() {

    var detailViewController: DetailViewController? = nil
    var gists = [Gist]()
    var nextPageURLString : String?
    var isLoading = false

    override func viewDidLoad() {
        super.viewDidLoad()
