finished unionAndIntersection, rotateList and flattenList