started refactoring of Repository, to reduce code duplication