fix scoping error in template