proper scoping for template var