move swap to method