fixed bug in history rearrangement mechanism