refactored to modular pattern