implemented swap