rewrite query.close