Use generator and min for performance