fixed the crash on focus lost