bug query function