Code quality refactoring