refactoring how to calculate the avarage rank at every time interval