Refactored for PHPMD compliance