Fixed scope error in template