Advanced Merging JS