             self.retrievingStories = false
             UIApplication.sharedApplication().networkActivityIndicatorVisible = false
           }
-          }, withCancelBlock: { error in
-            self.retrievingStories = false
-            self.stories.removeAll()
-            self.tableView.reloadData()
-            self.showErrorMessage(self.FetchErrorMessage)
-            UIApplication.sharedApplication().networkActivityIndicatorVisible = false
-        })
+          }, withCancelBlock: self.loadingFailed)
       }
-      }, withCancelBlock: { error in
-        self.retrievingStories = false
-        self.stories.removeAll()
-        self.tableView.reloadData()
-        self.showErrorMessage(self.FetchErrorMessage)
-        UIApplication.sharedApplication().networkActivityIndicatorVisible = false
-    })
+      }, withCancelBlock: self.loadingFailed)
+  }
+  
+  private func extractStory(snapshot: FDataSnapshot) -> Story {
+    let title = snapshot.value["title"] as! String
+    let url = snapshot.value["url"] as? String
+    let by = snapshot.value["by"] as! String
+    let score = snapshot.value["score"] as! Int
+    
+    return Story(title: title, url: url, by: by, score: score)
+  }
+  
+  private func loadingFailed(error: NSError!) -> Void {
+    self.retrievingStories = false
+    self.stories.removeAll()
+    self.tableView.reloadData()
+    self.showErrorMessage(self.FetchErrorMessage)
+    UIApplication.sharedApplication().networkActivityIndicatorVisible = false
   }
   
   func showErrorMessage(message: String) {

    let query = firebase.childByAppendingPath(StoryTypeChildRefMap[storyType]).queryLimitedToFirst(StoryLimit)
    query.observeSingleEventOfType(.Value, withBlock: { snapshot in
      let storyIds = snapshot.value as! [Int]
      for storyId in storyIds {
        let query = self.firebase.childByAppendingPath(self.ItemChildRef).childByAppendingPath(String(storyId))
        query.observeSingleEventOfType(.Value, withBlock: { snapshot in
          let title = snapshot.value["title"] as! String
          let url = snapshot.value["url"] as? String
          let by = snapshot.value["by"] as! String
          let score = snapshot.value["score"] as! Int
          let story = Story(title: title, url: url, by: by, score: score)
          storiesMap[storyId] = story
          
          if storiesMap.count == Int(self.StoryLimit) {
            var sortedStories = [Story]()

  // MARK: Structs
  
  struct Story {
    let title: String
    let url: String?
    let by: String
    let score: Int
  }
  
  // MARK: Initialization
