     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
+          storiesMap[storyId] = self.extractStory(snapshot)
           
           if storiesMap.count == Int(self.StoryLimit) {
             var sortedStories = [Story]()

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

            self.retrievingStories = false
            UIApplication.sharedApplication().networkActivityIndicatorVisible = false
          }
          }, withCancelBlock: self.loadingFailed)
      }
      }, 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) {
