refactor mutex lock & unlock