revise swap, add counter