Define all variables at beginning of function