refactoring for ReadRepository and ReadWriteRepository