Better solution to history off by one