Refactored to improve readability