refactored code into files