optmize: making WeightsMap.keys more efficient