Fixing mainWindow undefined error