ENH: Added function that implements step 1-4 in L and W.