added deadlock checking