refactor history page