Modified query.py