finished video 31 and implemented the query function