Refactored for easier customization