Removing duplicate code in CommonJSTmpl