fixed app crashing onResume and onPause