use aggregate to rewrite toMap and so on