Fixed invalid reference to variable