Re-factored business logic for populating template object to the template factory