Refactored for smaller methods