almost have activerecord implementation working