fix a big bug for dead lock