some modifications on query