added lock check
no code changes, only readability