                     }
                     
                 } else if type == HKCategoryTypeIdentifierSleepAnalysis {
+                    dispatch_group_leave(group)//leave main group
                     //HealthManager.sharedManager.getStatisticsForSleepInPeriod(period)
                 } else {
                     HealthManager.sharedManager.getStatisticForPeriod(period, forType: type) { (statisticsVlues) in
-                        let statisticsVluesData = NSKeyedArchiver.archivedDataWithRootObject(statisticsVlues)
-                        Defaults[key] = statisticsVluesData
+                        let statisticsValuesData = NSKeyedArchiver.archivedDataWithRootObject(statisticsVlues)
+                        Defaults[key] = statisticsValuesData
                         dispatch_group_leave(group)//leave main group
                     }
                 }

                    continue
                }
            }
            if (type == HKCategoryTypeIdentifierSleepAnalysis) {
                continue
            }
            for period in periods {
//                print("\(type) - \(period)")
                let key = UserManager.sharedManager.userId! + type + "\(period.rawValue)"
                //enter main group
                dispatch_group_enter(group)
                if period == HealthManagerStatisticsRangeType.Year {//if it's yaear most havy operation

            startDate = calendar.dateByAddingUnit(.Day, value: -31, toDate: endDate, options: [])!
        case .Year:
            endDate = endDateForYear
            if statisticsOptions == .CumulativeSum {
                interval.day = 1
            } else {
                interval.month = 1
            }
            anchorYearComponents.month -= 11
            anchorComponents = anchorYearComponents
            startDate = calendar.dateByAddingUnit(.Month, value: -11, toDate: endDate, options: [])!
