use swap function, clean up from linter