Refactored code with maintainers advice