got the query mechanism working as I wanted