fixed the crash on resume