Added onPause and onResume