Video 31 Implementing the query function