Reorganized logic to potentially avoid error in history view