Fixed query for empty collections.