refactored code into different files