Refactored the modules, encapsulating their functionality into functions to make execution and testing easier.