Refactoring $wrapTemplate