                 } catch let error {
                     DDLogError("Error moving cached file: \(error)")
                 }
-                
-                moc.perform {
+                self.perform { (moc) in
                     guard createItem else {
                         self.permanentCacheCompletionManager.complete(groupKey, identifier: identifier, enumerator: { (completion) in
                             completion.failure(ImageControllerError.fileError)

        }
    }
    
    @objc public func removePermanentlyCachedImages(groupKey: String, completion: @escaping () -> Void) {
        let moc = self.managedObjectContext
        let fm = self.fileManager
        moc.perform {
            self.permanentCacheCompletionManager.cancel(group: groupKey)
            guard let group = self.fetchCacheGroup(key: groupKey, moc: moc) else {
                completion()

    }
    
    @objc public func migrateLegacyImageURLs(_ imageURLs: [URL], intoGroup group: String, completion: @escaping () -> Void) {
        let legacyCacheFolderURL = self.legacyCacheFolderURL
        let legacyCacheFolderPath = legacyCacheFolderURL.path
        perform { (moc) in
            let group = self.fetchOrCreateCacheGroup(key: group, moc: moc)
            for imageURL in imageURLs {
                let key = self.cacheKeyForURL(imageURL)
