mutex lock/unlock added but not tested