This is going to be really slow. Instead make the Function an Eternal. You'll see these functions named in env.h and there are a few places like node.cc where there's a setup function that sets the method. If you need help doing that, let me know.