Refactoring of the code to seperate GUI code and logic