Correctly update history when scrolling