Refactored all the code into two separate files for easier reading