restructured code, details now in main window