fix a potential deadlock