Refactored code into modules