Refactor repository