fix crash when hitting back button