adds doSwap() function and makes it public.