refactoring mainwindow class