transfer separateElements to a functional version