 
 extension SAHistoryNavigationViewController: UINavigationBarDelegate {
   public func navigationBar(navigationBar: UINavigationBar, didPopItem item: UINavigationItem) {
-    screenshotImages.removeRange(navigationBar.items.count..<screenshotImages.count)
+    screenshots.removeRange(navigationBar.items.count..<screenshots.count)
   }
 }
 

    super.showHistory()

    if let image = visibleViewController.screenshotFromWindow(scale: SAHistoryNavigationViewController.kImageScale) {
      screenshotImages += [image]
    }

    historyDelegate?.historyControllerDidShowHistory(self, viewController: visibleViewController)

    historyViewController.images = screenshotImages
    historyViewController.currentIndex = viewControllers.count - 1
    historyViewController.reload()
    historyViewController.view.alpha = 1.0


  override public func pushViewController(viewController: UIViewController, animated: Bool) {
    if let image = visibleViewController.screenshotFromWindow(scale: SAHistoryNavigationViewController.kImageScale) {
      screenshots += [image]
    }
    super.pushViewController(viewController, animated: animated)
  }

  override public func popToRootViewControllerAnimated(animated: Bool) -> [AnyObject]? {
    screenshots.removeAll(keepCapacity: false)
    return super.popToRootViewControllerAnimated(animated)
  }

  override public func popToViewController(viewController: UIViewController, animated: Bool) -> [AnyObject]? {
    if let vcs = viewControllers as? [UIViewController],
      let index = find(vcs, viewController) {
        screenshots.removeRange(index..<screenshots.count)
    }
    return super.popToViewController(viewController, animated: animated)
  }
