Why is a global variable being assigned in an instance method?