fix to avoid null pointer exceptions when the activity stops