Use itertools methods; modify get_index()