abstracted some code away from the main window