adding swap alternodes code