Fixed variable scopes in example