Added statistics code