refactor the ActiveRecord::Relation hack