refactored jinja2 work