refactored to use Jinja templates
merged with remote