move global and collection-specific counts inside if/else condition on x
value