fixed a potential deadlock