implement chain swapping