small refactor to template-expand.el