convert sum to IndexSum to handle C convention indices properly