Refactored code into separate file