fix bug in stats calc