re-open query function