Move function into a lexical scope