fragment null check added - fixes bug when the fragment is destroyed before the activity for some reason.