video 30: implementing the query function