add mutex for safemaze