Bug/fix nil error

Use try to avoid raising NoMethodError for nil:NilClass