Refactoring and reusing Error normalization code