swap functionality in place