Tinkered with the function hooking logic