Make sure cursor.collection exists

If you use `nextObject` method of a `cursor` object on a non-existent collection it crashes your application. Found and fixed with @humanchimp