changed mergeAttributes function