foreach at inner loop - double reduse still eludes me