codes for main window