Refactor historyViewController