move global function into scope