Fix issue with scoping of var

prior to this commit the var in question was not in scope as it was not
global