fixed swapping problem