     {
         guard let viewController = viewController else { return nil }
         
-        return RoutingLogic.present(
-            delegate: viewController,
-            storyboard: storyboard,
-            inBundle: bundle,
-            identifier: identifier,
-            animated: animated,
-            modalPresentationStyle:
-            modalPresentationStyle,
-            modalTransitionStyle: modalTransitionStyle,
-            configure: configure,
-            completion: completion
-        )
-    }
-    
-    /// Present the intial view controller of the specified storyboard in the primary context.
-    /// Set the initial view controller in the target storyboard or specify the identifier.
-    ///
-    /// - Parameters:
-    ///   - storyboard: Storyboard name.
-    ///   - bundle: Bundle of the storyboard.
-    ///   - identifier: Storyboard identifier.
-    ///   - configure: Configure the view controller before it is loaded.
-    /// - Returns: Returns the view controller instance from the storyboard.
+        let storyboard = UIStoryboard(name: storyboard, bundle: bundle)
+        
+        guard let controller = (identifier != nil
+            ? storyboard.instantiateViewController(withIdentifier: identifier!)
+            : storyboard.instantiateInitialViewController()) as? T else {
+                assertionFailure("Invalid controller for storyboard \(storyboard).")
+                return nil
+        }
+        
+        if let modalPresentationStyle = modalPresentationStyle {
+            controller.modalPresentationStyle = modalPresentationStyle
+        }
+        
+        if let modalTransitionStyle = modalTransitionStyle {
+            controller.modalTransitionStyle = modalTransitionStyle
+        }
+        
+        configure?(controller)
+        
+        viewController.present(controller, animated: animated) {
+            completion?(controller)
+        }
+        
+        return controller
+    }
+}
+
+public extension Router {
+    
     func show<T: UIViewController>(
         storyboard: String,
         inBundle bundle: Bundle? = nil,

    {
        guard let viewController = viewController else { return nil }
        
        return RoutingLogic.showDetailViewController(
            delegate: viewController,
            storyboard: storyboard,
            inBundle: bundle,
            identifier: identifier,
            configure: configure
        )
    }
    
    /// Dismisses or pops the view controller that was presented.
    ///
    /// - Parameters:
    ///   - animated: Pass true to animate the presentation; otherwise, pass false.
    ///   - completion: The block to execute after the view controller is dismissed.
    func dismiss(animated: Bool = true, completion: (() -> Void)? = nil) {
        guard let viewController = viewController else { return }
        
        return RoutingLogic.dismiss(
            delegate: viewController,
            animated: animated,
            completion: completion
        )
    }
}

// MARK: - Private functions

fileprivate enum RoutingLogic {
    
    static func present<T: UIViewController>(
        delegate: UIViewController,
        storyboard: String,
        inBundle bundle: Bundle? = nil,
        identifier: String? = nil,
        animated: Bool = true,
        modalPresentationStyle: UIModalPresentationStyle? = nil,
        modalTransitionStyle: UIModalTransitionStyle? = nil,
        configure: ((T) -> Void)? = nil,
        completion: ((T) -> Void)? = nil) -> T?
    {
        let storyboard = UIStoryboard(name: storyboard, bundle: bundle)
        
        guard let controller = (identifier != nil
            ? storyboard.instantiateViewController(withIdentifier: identifier!)
            : storyboard.instantiateInitialViewController()) as? T else {
                assertionFailure("Invalid controller for storyboard \(storyboard).")
                return nil
        }
        
        if let modalPresentationStyle = modalPresentationStyle {
            controller.modalPresentationStyle = modalPresentationStyle
        }
        
        if let modalTransitionStyle = modalTransitionStyle {
            controller.modalTransitionStyle = modalTransitionStyle
        }
        
        configure?(controller)
        
        delegate.present(controller, animated: animated) {
            completion?(controller)
        }
        
        return controller
    }

    static func show<T: UIViewController>(
        delegate: UIViewController,
        storyboard: String,
        inBundle bundle: Bundle? = nil,
        identifier: String? = nil,
        configure: ((T) -> Void)? = nil) -> T?
    {
        let storyboard = UIStoryboard(name: storyboard, bundle: bundle)
        
        guard let controller = (identifier != nil
            ? storyboard.instantiateViewController(withIdentifier: identifier!)
            : storyboard.instantiateInitialViewController()) as? T else {
                assertionFailure("Invalid controller for storyboard \(storyboard).")
                return nil
        }
        
        configure?(controller)
        
        delegate.show(controller, sender: delegate)
        
        return controller
    }

    static func showDetailViewController<T: UIViewController>(
        delegate: UIViewController,
        storyboard: String,
        inBundle bundle: Bundle? = nil,
        identifier: String? = nil,
        configure: ((T) -> Void)? = nil) -> T?
    {
        let storyboard = UIStoryboard(name: storyboard, bundle: bundle)
        
        guard let controller = (identifier != nil
            ? storyboard.instantiateViewController(withIdentifier: identifier!)
            : storyboard.instantiateInitialViewController()) as? T else {
                assertionFailure("Invalid controller for storyboard \(storyboard).")
                return nil
        }
        
        configure?(controller)
        
        delegate.showDetailViewController(controller, sender: delegate)
        
        return controller
    }
    
    static func dismiss(delegate: UIViewController, animated: Bool = true, completion: (() -> Void)? = nil) {
        guard let navController = delegate.navigationController else {
            delegate.dismiss(animated: true, completion: completion)
            return
        }
        
        guard navController.viewControllers.count > 1 else {
            return navController.dismiss(animated: true, completion: completion)
        }
        
        navController.popViewController(animated: true, completion: completion)
    }
}

    {
        guard let viewController = viewController else { return nil }
        
        let storyboard = UIStoryboard(name: storyboard, bundle: bundle)
        
        guard let controller = (identifier != nil
            ? storyboard.instantiateViewController(withIdentifier: identifier!)
            : storyboard.instantiateInitialViewController()) as? T else {
                assertionFailure("Invalid controller for storyboard \(storyboard).")
                return nil
        }
        
        configure?(controller)
        
        viewController.show(controller, sender: viewController)
        
        return controller
    }
    
    func showDetailViewController<T: UIViewController>(
        storyboard: String,
        inBundle bundle: Bundle? = nil,
