fix bug in query on an empty collection