Refactored functionality into separate files