     }
     
     public func deleteData(at date: Date, id: HKQuantityTypeIdentifier, completion: @escaping Callback<Bool>) {
-        let resultsHandler = { (_: HKSampleQuery, samples: [HKSample]?, error: Error?) in
-            if let error = error {
-                completion(Result.failure(SHKError.from(error)))
-                return
-            }
-            guard let items = (samples?.filter { date.isInSameDay(at: $0.startDate) }), items.count > 0 else {
-                // Nothing to delete
-                completion(Result.success(true))
-                return
-            }
-            
-            self.delete(samples: items, completion: completion)
-        }
-        
         let query = HKSampleQuery(
             sampleType: id.type,
             predicate: predicateForOneDay(date: date),
             limit: HKObjectQueryNoLimit,
             sortDescriptors: nil,
-            resultsHandler: resultsHandler)
+            resultsHandler: { _, samples, error in
+                if let error = error {
+                    completion(Result.failure(SHKError.from(error)))
+                    return
+                }
+                guard let items = (samples?.filter { date.isInSameDay(at: $0.startDate) }), items.count > 0 else {
+                    // Nothing to delete
+                    completion(Result.success(true))
+                    return
+                }
+                
+                self.delete(samples: items, completion: completion)
+            }
+        )
         store.execute(query)
     }
     

        return HKQuery.predicateForSamples(
            withStart: date.startOfDay,
            end: date.endOfDay,
            options: .strictStartDate
        )
    }
}


    // Singleton
    // http://stackoverflow.com/questions/35591466/create-singleton-instance-via-extension-per-app
    //
    public static let shared = SwiftyHealthKit()
    private init() {}
    public let store = HKHealthStore()
    
