minor query changes for speedup