Renaming attribute and abstracting the swapping code a little