supports recursion for locking