Flatten Function added