fixed deadlock situation with new algo