Added history and new calculation logic.