refactored some of the code and moved the entry logic to the Main class