Instead of count(), check entity ids.