Now also takes into account the class attributes on the original elements