fix some bug in query.py