detect different classes in merge operation