fix bug with multiple instances