mutex lock to prevent thread concurrency