Understanding the scope of variables