reduce if and case in unfold()