Made function to remove duplicates after flattening
Commented code.
Fixed removeDuplicates function.