moved swapping to ioutils class