refactored code into modules