history calculation