updated robot query function