swap function and tip added