changing to activerecord