anonymous function for a new scope so as to maintain a copy of the value for a var in the parent scope