swap variables, fix a template issue