Refactored repository class for better performance