Swap nodes in pairs - refactor