added locking / unlocking of mutex.