extract common method
process template with vars