add funcution to swap