fix a function's scope