Simplify statistics code