check for null value before using the attribute