Refactored code into sep. files