Added history functionality for swapping