fix NoMethodError on nil object