updated query.py to make more sense