refactoring to pass context param to template