fixed deadlock bug