clean up swap logic