Refactored code into smaller modules