Fixes performance issue with counts