             CATransaction.commit()
         CATransaction.commit()
         
-        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(0.9 * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), {
+        dispatchAfter(0.9) {
             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(), {
+                
+                dispatchAfter(dismissDelay) {
                     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(), {
+        
+        dispatchAfter(dismissDelay) {
             hideLoader(currentLoader, withCompletionBlock: currentCompletionBlock)
-        })
+        }
     }
     
     func cleanup() {

    
    let backgroundView = loader.backgroundView
    
    UIView.animateWithDuration(config.backgroundViewDismissAnimationDuration, delay: 0.0, options: .CurveEaseOut, animations: {
        backgroundView.alpha = 0.0
        backgroundView.transform = CGAffineTransformMakeScale(0.9, 0.9)
    }, completion: { _ in block?() })
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(config.backgroundViewDismissAnimationDuration * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), { () -> Void in
        cleanupLoader(loader)
    })
}

private func window() -> UIWindow? {

    }
    
}

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)
}
