Rewrote code for usage with collection-instances