             DispatchQueue.main.async {
                 let timer = Timer.scheduledTimer(withTimeInterval: TimeInterval(updateInterval), repeats: false) { (timer) in
                     
-                    self.downloadDatafile(sdkKey: sdkKey) { (result) in
-                        switch result {
-                        case .success(let data):
-                            if let data = data,
-                                let datafileChangeNotification = datafileChangeNotification {
-                                datafileChangeNotification(data)
-                            }
-                        case .failure(let error):
-                            self.logger?.log(level: .error, message: error.localizedDescription)
-                        }
-
-                        if self.hasPeriodUpdates(sdkKey: sdkKey) {
-                            self.startPeriodicUpdates(sdkKey: sdkKey, updateInterval: updateInterval, datafileChangeNotification: datafileChangeNotification)
-                        }
-                    }
+                    self.performPerodicDownload(sdkKey: sdkKey, updateInterval: updateInterval, datafileChangeNotification: datafileChangeNotification)
                     
                     timer.invalidate()
                 }

            }
        } else {
            // Fallback on earlier versions
        }
    }
    
    func hasPeriodUpdates(sdkKey: String) -> Bool {

        return restart
    }
    
    func performPerodicDownload(sdkKey: String,
                                updateInterval:Int,
                                datafileChangeNotification:((Data)->Void)?) {
        self.downloadDatafile(sdkKey: sdkKey) { (result) in
            switch result {
            case .success(let data):
                if let data = data,
                    let datafileChangeNotification = datafileChangeNotification {
                    datafileChangeNotification(data)
                }
            case .failure(let error):
                self.logger?.log(level: .error, message: error.localizedDescription)
            }
            
            if self.hasPeriodUpdates(sdkKey: sdkKey) {
                self.startPeriodicUpdates(sdkKey: sdkKey, updateInterval: updateInterval, datafileChangeNotification: datafileChangeNotification)
            }
        }
    }
    
    func stopPeriodicUpdates(sdkKey: String) {
        timers.performAtomic { (timers) in
            if let timer = timers[sdkKey] {
