Fix swapping bug