refactor bubble sort swapElement closure