Check for null before assigning