Modified the hooking logic.