Query moved from controller to repository class