implemented query function