itertools is a teeny bit more elegant