added lock and unlock functions, yet untested