Restructured takingWhile and its documentation