fix scope for thread protection mutex