added deadlock check