Added support for incollection and fixed a bug