implemented lock and unlock