Add method swap function.