 			let originalSelector = #selector(UIViewController.prepare(for:sender:))
 			let swizzledSelector = #selector(UIViewController.swizzledPrepare(for:sender:))
 			
-			let originalMethod = class_getInstanceMethod(UIViewController.self, originalSelector)
-			let swizzledMethod = class_getInstanceMethod(UIViewController.self, swizzledSelector)
+			let originalMethod = class_getInstanceMethod(self.classForCoder, originalSelector)
+			let swizzledMethod = class_getInstanceMethod(self.classForCoder, swizzledSelector)
 			
 			method_exchangeImplementations(originalMethod, swizzledMethod)
 			
 			UIViewController.isPrepareForSegueSwizzled = true
 		}
 		
-		self.performingSegueIdentifier = identifier
-		self.performingSegueCompletionHandler = { viewController in
+		self.performingSegueData = SegueHandlerData(segueIdentifier: identifier) {
+			(viewController: UIViewController) in
 			(viewController as? T).map { prepareHandler?($0) }
 		}
 		

	}
	
	@objc private func swizzledPrepare(for segue: UIStoryboardSegue, sender: Any?) {
		if let performingSegueIdentifier = self.performingSegueIdentifier,
			segue.identifier == performingSegueIdentifier
		{
			self.performingSegueIdentifier = nil
			
			self.performingSegueCompletionHandler?(segue.destination)
			
			self.performingSegueCompletionHandler = nil
		}
		else {
			self.swizzledPrepare(for: segue, sender: self)
		}
	}
	
}


import UIKit

private typealias SegueHandler = (UIViewController) -> ()

private var kAssociatedSwizzleState = false
private var kAssociatedSegueData = "associatedSegueData"

private class SegueHandlerData {
	let segueIdentifier: String
	let segueHandler: SegueHandler?
	
	init (segueIdentifier: String, segueHandler: SegueHandler? = nil) {
		self.segueIdentifier = segueIdentifier
		self.segueHandler = segueHandler
	}
}

public extension UIViewController {
	
	private static var isPrepareForSegueSwizzled: Bool {
		get {
			return objc_getAssociatedObject(self, &kAssociatedSwizzleState) as? Bool ?? false
		}
		set {
			objc_setAssociatedObject(self,
			                         &kAssociatedSwizzleState,
			                         newValue,
			                         objc_AssociationPolicy.OBJC_ASSOCIATION_ASSIGN)
		}
	}
	
	private var performingSegueData: SegueHandlerData? {
		get {
			return objc_getAssociatedObject(self, &kAssociatedSegueData) as? SegueHandlerData
		}
		set {
			objc_setAssociatedObject(self,
			                         &kAssociatedSegueData,
			                         newValue,
			                         objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN)
		}
	}
	
