Protect against “NoMethodError: undefined method `empty?' for nil:NilClass”