Count query fix