Refactory the repository inherit hierarchy