better swap function
added main function