added statistics code