swapping bug fixed