move a variable to a more correct scope