Check for null ref befor getting the attributes