replace checks where .Count() > 0 with .Any() to optimize the code performance