removed redudant looping if no further swaps