Slight improvement to #22, using map.with_index