finished lock implementation