Fix count query