Fixed bug with swapping