Create swap_function