A more mapreduce-ish approach.