rewrite mutex lock