Added a nil check on a rangeOfString: method call.