Fix count query issue