Refactoring for better maintainability