adding swap function