updated to work with multiple instances in one page, and added an example for this