Add var to undeclared variables and a function wrapper