add mutex code (no modification)