partial refactoring to AR