Work with Ruby 1.8.7

Use each_with_index instead of map.with_index.