Replace calls to count with exists