refactored for external configuration