                                 default:
                                     viewControllers.append(newViewController) // Create the view controller and append it to the navigation view controller stack
                                 }
+                            }
                         }
                     }
                 }
-            }
-            navController.viewControllers = viewControllers // Apply the updated list of view controller to the current navigation controller.
+                navController.viewControllers = viewControllers // Apply the updated list of view controller to the current navigation controller.
+            }
         }
     }
     

    
    func themeApp() {
        window?.tintColor = NSAssetKit.predefinedNeutralColor
        // Change the font and size of nav bar text
        if let navBarFont = UIFont(name: "HelveticaNeue-Thin", size: 20.0) {
            
            let navBarColor: UIColor = NSAssetKit.darkNavColor

    // MARK: Local Notifications
    
    func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) {
        // println("Received a local notification payload: \(notification)")
        if let userInfoDict : [NSObject : AnyObject] = notification.userInfo {
            if let uuidString = userInfoDict[Site.PropertyKey.uuidKey] as? String {
                let uuid = NSUUID(UUIDString: uuidString) // Get the uuid from the notification.
                let site = sites.filter{ $0.uuid == uuid }.first // Use the uuid value to get the site object from the array.
                let siteIndex = find(sites, site!) // Use the site object to get its index position in the array.
                
                site?.notifications.removeAtIndex(find(site!.notifications, notification)!)
                AppDataManager.sharedInstance.updateSite(site!)
                AppDataManager.sharedInstance.currentSiteIndex = siteIndex!
                
                // println("User tapped on notification for site: \(site) at index \(siteIndex)")
                
                let url = NSURL(string: "nightscouter://link/\(UIStoryboard.StoryboardViewControllerIdentifier.SiteListPageViewController.rawValue)")
                if let site = (sites.filter{ $0.uuid == uuid }.first) { // Use the uuid value to get the site object from the array.
                    if let siteIndex = find(sites, site) { // Use the site object to get its index position in the array.
                        AppDataManager.sharedInstance.currentSiteIndex = siteIndex
                        if let notificationIndex  = find(site.notifications, notification) {
                            site.notifications.removeAtIndex(notificationIndex)
                            // println("User tapped on notification for site: \(site) at index \(siteIndex)")
                            
                            let url = NSURL(string: "nightscouter://link/\(UIStoryboard.StoryboardViewControllerIdentifier.SiteListPageViewController.rawValue)")
                            deepLinkToURL(url!)
