             return sections.count
         }
         if let index = item as? Int {
-            return sections[index].numOfChild(streamsOfCategories)
+            return sections[index].numOfChild(streamListDic)
         }
         return 0
     }

        mainViewController?.showCenterPanelAnimated(true)
    }

    func fetch() {
        sections = [Section.All, Section.Pocket]
        if apiClient.isLoggedIn {
            fetchCategories()
        } else {
            fetchTrialFeeds()
        }
    }

    func fetchCategories() {
        self.refreshControl?.beginRefreshing()
        apiClient.fetchCategories()
            .deliverOn(MainScheduler())
            .start(next: {categories in
                for category in categories {
                    self.streamsOfCategories[category] = []
                    self.sections.append(Section.FeedlyCategory(category))
                    println("id \(category.id) label \(category.label)")
                }
            },
            error: {error in
                self.refreshControl?.endRefreshing()
                return
            },
            completed: {
                self.refreshControl?.endRefreshing()
                self.fetchSubscriptions()
        });
    }

    func fetchSubscriptions() {
        self.refreshControl?.beginRefreshing()
        apiClient.fetchSubscriptions()
            .deliverOn(MainScheduler())
            .start(
                next: {subscriptions in
                    for subscription in subscriptions {
                        for c in subscription.categories {
                            self.streamsOfCategories[c]!.append(subscription)
                        }
                    }
                },
                error: {error in
                    self.refreshControl?.endRefreshing()
                    return
                },
                completed: {
                    self.refreshControl?.endRefreshing()
                    self.treeView!.reloadData()
            })
    }

    func fetchTrialFeeds() {
        self.refreshControl?.beginRefreshing()
        apiClient.fetchFeedsByIds(appDelegate.trialFeeds)
            .deliverOn(MainScheduler())
            .start(
                next: {feeds in
                    let samplesCategory = FeedlyKit.Category(id: "feed/musicfav-samples", label: "Sample Feeds")
                    self.sections.append(Section.FeedlyCategory(samplesCategory))
                    self.streamsOfCategories = [samplesCategory:feeds]
                },
                error: {error in
                    self.refreshControl?.endRefreshing()
                    return
                },
                completed: {
                    self.refreshControl?.endRefreshing()
                    self.treeView!.reloadData()
            })
    }

    func unsubscribeTo(subscription: Subscription, index: Int, category: FeedlyKit.Category) {

            cell.textLabel?.text = "Nothing"
        } else if let index = item as? Int {
            let section = sections[index]
            let num     = section.numOfChild(streamListDic)
            if num > 0 {
                cell.textLabel?.text = "\(section.title) (\(section.numOfChild(streamListDic)))"
            } else {
                cell.textLabel?.text = "\(section.title)"
            }
