implemented onPause and onResume