now the swap function works good also for history changes