added check for dead lock