now it works correctly with multiple instances