fixed a deadlock bug