a bit of control flow, map and reduce