fixed problem in queries when collections of objects are used,
exploiting inference