optimize swaps