bug fix - calling activerecord methods on nil