Fixed range bug when swapping