fixed statistics code