code quality refactorins & formatting