staged + modified mainwindow.cpp