adding support for multiple instances. fixes #24