Adding onPause and onResume functions