video 31: implementing the query Function