restructured code so that it use _repr_..._ instead of returning a HTML class