     }
     
     
-    // MARK: - internal methods
-    func fetchDataForModelName(modelName:String, success:((data:AnyObject?)->Void)?, failure:((error:NSError)->Void)?){
+    // MARK: - public methods
+    public func fetchDataForModelName(modelName:String, success:((data:AnyObject?)->Void)?, failure:((error:NSError)->Void)?){
         /* fetch cached data */
         if let cachedData: AnyObject? = fetchDataFromCoredataForModelName(modelName), successBlock = success {
             successBlock(data: cachedData)
         }
-        
+        /* if delegate is nil, return */
         if self.delegate == nil {
             return
         }
+        /* fetch data from network */
         self.delegate!.fetchDataFromNetworkForModelName(modelName, success: { (data) -> Void in
             self.updateCacheForModelName(modelName, data: data)
-                if let successBlock = success {
-                    successBlock(data: data)
-                }
-            }, failure:{(error)->Void in
-                if let failureBlock = failure {
-                    failureBlock(error: error)
-                }
+            success?(data: data)
+        }, failure:{(error)->Void in
+            failure?(error: error)
         })
     }
     

            request.entity = NSEntityDescription.entityForName(kEntityName, inManagedObjectContext: context)
            let predicate = NSPredicate(format: "%K == %@", kModelNameAttributeName, modelName)
            request.predicate = predicate
            var error:NSError?
            do {
                let results = try context.executeFetchRequest(request)
                for item in results {
                    context.deleteObject(item as! NSManagedObject)
                }
            } catch let error1 as NSError {
                error = error1
            } catch {
                fatalError()
            }

            error = NSError(domain: "YOUR_ERROR_DOMAIN", code: 9999, userInfo: dict)
            // Replace this with code to handle the error appropriately.
            // abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
            NSLog("Unresolved error \(error), \(error.userInfo)")
            abort()
        } catch {
            fatalError()
