fixed the swap bug