Implement MergeUnion and do some refactor in Main