Refactoring for maintainability