     func collectionCenters(whichNeed product: String, completion: @escaping (_ result: [JUWCollectionCenter]) -> Void) {
         let query = product.lowercased().stripCharacters(in: CharacterSet.alphanumerics.inverted)
         precondition(!query.isEmpty, "Query should not be empty")
-        
-        var collectionCenter: [JUWCollectionCenter] = []
         guard let url = String(format: kCollectionCenterSearchProductUrl, query).encoded() else {
-            DispatchQueue.main.async { completion(collectionCenter) }
+            DispatchQueue.main.async { completion([]) }
             return
         }
         networkManager.get(url: url, completion: { (result) in
-            guard let array = result as? [Any]  else {
-                DispatchQueue.main.async { completion(collectionCenter) }
+            guard let array = result as? [[String: Any]]  else {
+                DispatchQueue.main.async { completion([]) }
                 return
             }
-            
             let realm = try! Realm()
-            for value in array {
-                if let dictionary = value as? [String: Any] {
-                    let predicate = NSPredicate(format: "centerIdentifier = %@", dictionary["acopioId"] as! String)
-                    if let center = realm.objects(JUWCollectionCenter.self).filter(predicate).first {
-                        collectionCenter.append(center)
-                    }
-                }
-            }
-            DispatchQueue.main.async { completion(collectionCenter) }
+            let centers = realm.collectionCenters(with: array)
+            DispatchQueue.main.async { completion(centers) }
         }) { (error) in
-            DispatchQueue.main.async { completion(collectionCenter) }
+            DispatchQueue.main.async { completion([]) }
         }
     }
     

        
    }
}

    
    func updateCollectionCenters(centers: @escaping () -> Void, failure: @escaping (_ error: Error) -> Void) {
        networkManager.get(url: kCollectionCentersUrl, completion: { result in
            guard let array = result as? [[String: Any]]  else {
                DispatchQueue.main.async { centers() }
                return
            }
            let realm = try? Realm()
            realm?.deleteCollectionCenters(notIn: array)
            realm?.addCollectionCenters(in: array)
            DispatchQueue.main.async { centers() }
        }) { (error) in
            failure(error!)
        }
