refactored code, making code modular