refactor update_template

more abstract and reusable
Merge branch 'master' into production