active record refactor