Fixed NoMethodError if  is nil.