added logic to only save the history file if it's been modified since the last update