added lock and unlock functions, which lock both next and prev.