Refactoring code into modules