fix crash bug - check nil for [NSString:rangeOfString:]