add jinja template and bugs solved