#2 added functionality for multiple templates