Using isKindOfClass to avoid nil