implemented unite function, may need more test cases