implemented swap stuff