fixed bug if less than 3 elements in history