added function to do instancing