rewrite mainwindow.cpp to use helper