refactor repository model