Refactor Generic repository