renaming lock to with_lock