Fixed a bug related to variable scopes