Correct logic error in swapping dimensions