add variables to template and replace them
code refactoring - need to improve