     }
     
 }
+
+private func dispatchAfter(time: Double, block: dispatch_block_t) {
+    let dispatchTime = dispatch_time(DISPATCH_TIME_NOW, Int64(time * Double(NSEC_PER_SEC)))
+    dispatch_after(dispatchTime, dispatch_get_main_queue(), block)
+}
+
+private func dispatchOnMainQueue(block: dispatch_block_t) {
+    dispatch_async(dispatch_get_main_queue(), block)
+}

            CATransaction.commit()
        CATransaction.commit()
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(0.9 * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), {
            if config.showSuccessCheckmark {
                Status.show(.Success)
                
                let dismissDelay = 0.5 + max(config.successCircleAnimationDrawDuration, config.checkmarkAnimationDrawDuration)
                dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(dismissDelay * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), {
                    hideLoader(currentLoader, withCompletionBlock: currentCompletionBlock)
                })
            } else {
                hideLoader(currentLoader, withCompletionBlock: currentCompletionBlock)
            }
        })
    }
    
    func failedLoading() {
        Status.show(.Fail)
        let dismissDelay = 0.5 + max(config.failCircleAnimationDrawDuration, config.failCrossAnimationDrawDuration)
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(dismissDelay * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), {
            hideLoader(currentLoader, withCompletionBlock: currentCompletionBlock)
        })
    }
    
    func cleanup() {

            Status.drawFail(loader.backgroundView)
        }
        
        dispatchAfter(1.25) {
            hideLoader(loader, withCompletionBlock: nil)
        }
    }
    
}
