refactored code into multiple files