updated to use jinja2 template engine