refactoring on template add method to return the inserted template