fixing template scope lookup