Fixed issue with dynamic hook on document when the function is a string