Refactored the code into seperate files.