adding query function, and friends query