refactor ajax of history