Add query function.