Refactor 3 of the index steps using macro.