changed the calculation of statistics to work