revise to use jinja2 template engine