refactor orm