Refactored code into small modules