Rewrite some of mutual exclusion