check nil condition for nserror to avoid crash