Refactored entity repo