refactor orm structure