fixes NoMethodError: undefined method `empty?' for nil:NilClass