improved merge so categories no longer get duplicated