Refactors an anonymous function to be a named scope-wide function.