Refactored method slightly for better readability