move swap into a central location