fixed statistics code for custom callbacks