Reimplement iterate using unfold